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

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

Parameters

campaignCode
Type: SystemString
Campaign UTM code
siteName
Type: SystemString
Name of the site the campaign belongs to
source (Optional)
Type: SystemString
Name of the campaign UTM source
content (Optional)
Type: SystemString
Campaign UTM content
Remarks
If Javascript logging is enabled, hit logging will be performed asynchronously on the following request.
Examples
Following example shows how to use the SetCampaign(String, String, String, String) method.
var campaignService = new CampaignService();

...

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

...

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


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


// returns myContent
public string GetCampaignContent() 
{
    return campaignService.CampaignSourceName;
}
See Also