Triggering a campaign
A campaign is a promotion or advertising initiative that is represented by a definition item in Sitecore, and is often associated with a landing page. There are three ways to trigger a campaign:
-
Assign a campaign definition item to the page and visit the published page.
NoteYou can only assign one campaign to a page.
-
Use the campaign query string (
sc_camp
by default) when visiting the page.
The following logic applies when a visitor triggers a campaign:
-
If the campaign is triggered on the landing page (the first page of the interaction):
-
Set the tracker interaction's
Tracker.Current.Session.Interaction.CampaignId
. -
On session end, set the xConnect interaction's
Sitecore.XConnect.Interaction.CampaignId
and add aCampaignEvent
object to the interaction'sSitecore.XConnect.Interaction.Events
collection.
NoteThe
CampaignId
property is only set it if it is empty. If you trigger multiple campaigns on the landing page, theCampaignId
property represents the campaign that was triggered first. -
-
If the campaign is triggered on a subsequent page, add a campaign
PageEventData
to the tracker interaction. On session end, add aCampaignEvent
to the xConnect interaction'sSitecore.XConnect.Interaction.Events
collection. TheCampaignId
property is not set.
Understanding campaign data in reporting interfaces
The Experience Analytics (xAnalytics) reports rely on aggregated data in the xDB Reporting database. The interaction aggregation pipelines only process interaction-level campaigns (represented by the Sitecore.XConnect.Interaction.CampaignId
property), which means that campaigns triggered on the second or subsequent pages of an interaction are not included in the aggregated reporting data.
Troubleshoot campaigns
To check whether a campaign is being triggered in the xDB Collection SQL provider:
-
In SQL Management Studio, expand an xDB Collection database shard (for example,
[yourproduct]_Xdb.Collection.Shard[X]
). -
Select the top X rows of the
xdb_collection.Interactions
table. -
Locate the
CampaignId
andEvents
columns.-
If the
CampaignId
column has a value, the campaign was successfully triggered on the first page of the interaction. The same campaign is represented in theEvents
column JSON. This data is included in the xAnalytics campaign reports. -
If the
CampaignId
column isNULL
, any campaign that was successfully triggered on the second or subsequent pages is represented in theEvents
column JSON. This data is not used in the xAnalytics campaign reports.
If the campaign is not represented in the
Events
column or theCampaignId
column, it has not been triggered. -
If a campaign has not been triggered:
-
Ensure that you have published and deployed the campaign definition item to the Reference Data database.
-
If you are using a query string to trigger the campaign, ensure that you are using the correct query string key. The
Analytics.CampaignQueryStringKey
setting is located in theApp_Config\Sitecore\Marketing.Tracking\Sitecore.Analytics.Tracking.config
configuration file by default:RequestResponse<setting name="Analytics.CampaignQueryStringKey" value="sc_camp" />
NoteIf you are using patch files to change your configuration, use the
/sitecore/admin/showconfig.aspx
interface to check the final value of theAnalytics.CampaignQueryStringKey
setting.