Click or drag to resize
CampaignServiceSetCampaign Method
If CampaignInfo with given campaignCode exists and is running, sets both campaignCode and source to their properties (CampaignCode or CampaignSourceName respectively).

Namespace: CMS.WebAnalytics
Assembly: CMS.WebAnalytics (in CMS.WebAnalytics.dll) Version: 10.0.0
Syntax
C#
public void SetCampaign(
	string campaignCode,
	string siteName,
	string source = null
)

Parameters

campaignCode
Type: SystemString
Name of the campaign to be set
siteName
Type: SystemString
Name of the site the campaignCode belongs to
source (Optional)
Type: SystemString
Name of the campaign source

Implements

ICampaignServiceSetCampaign(String, String, String)
Exceptions
ExceptionCondition
ArgumentExceptioncampaignCode is null -or- siteName is null or empty
Examples
Following example shows how to use the SetCampaign(String, String, String) method.
var campaignService = new CampaignService();

...

// stores myCampaign to the <see cref="P:CMS.WebAnalytics.CampaignService.CampaignCode" /> and mySource to the <see cref="P:CMS.WebAnalytics.CampaignService.CampaignSourceName" />
campaignService.SetCampaign("myCampaign", "mySite", "mySource");

...

// for all following requests of the same visitor
// returns myCampaign
public string GetCampaignCode() 
{
    return campaignService.CampaignCode;
}


// returns mySource
public string GetSourceName() 
{
    return campaignService.CampaignSourceName;
}
See Also