Mark's Sitecore Blog

Understanding Sitecore DMS Campaign triggering

campaign on landing pageSitecore DMS allows you to launch and track Campaigns. You can set up Campaigns inside Marketing Center. Check the Marketing Operations Cookbook on SDN for more detail on that. Make sure you deploy your Campaigns by clicking Deploy in the Review ribbon afer setting them up. Now your Campaigns are ready to be triggered.

Campaigns can be triggered…

  • via URL parameter ?sc_camp=myCampaignId
  • via Landing page (see screen shot)

Every time a Campaign is triggered, the triggerCampaign pipeline runs. Here, rules are executed, automation is run and the Campaign page event is registered.

If you want to access the Campaign for the current Visit, use:

var currentCampaignId = Tracker.CurrentVisit.CampaignId;

How Campaigns work together with Visits

What is a bit hard to understand at first is, how Campaigns play along with DMS Visits. It is important to know that by default, Campaigns are associated to visits only if

  • no other Campaign has been associated with the visit yet
  • the page view is the first page of the current visit (Landing Page).

To clarify this, here’s what happens inside the StartTracking pipeline:

if (Tracker.CurrentVisit.IsCampaignIdNull() && Tracker.CurrentVisit.IsOnLandingPage())
    Tracker.CurrentVisit.CampaignId = campaign.ID.ToGuid();
... run the triggerCampaign pipeline

This makes debugging a bit complicated because you need to clear cookies and make sure you trigger the Campaign on the first page you’re opening. But in most real world scenarios it will work well. (i.e. leading customers to your site through social media, landing pages,…)

Modifying the way Campaigns are associated to Visits

But what if you would want to be able to trigger a Campaign during a Visit (not only on the landing page) or if you would want to be able to override a previously assigned campaign?
This is possible. You need to hook into the triggerCampaign pipeline and set the Visit’s Campaign ID when a Campaign gets triggered:

Keep in mind that this will affect your Campaign reporting. Visits assigned to Campaign A and then re-assigned to Campaign B won’t be shown on the stats for Campaign A anymore. The engagement value earned during Campaign A will then show up on stats for Campaign B.

I hope this gets you started with Sitecore DMS Campaigns.

Tagged on: , , ,

4 thoughts on “Understanding Sitecore DMS Campaign triggering

  1. Pingback: A List of Custom Sitecore DMS Functionality | Sitecore.Context.Item

  2. techcolin

    This was hugely useful – thanks! Trying to test campaign tracking is extremely challenging if you’re not aware of the fact Sitecore won’t track the campaign if it’s not the first visit. This means we need to make use of Private Windows in Firefox (even Chrome Incognito holds on to the visit ID somehow) to test.

    1. Mark Post author

      If you’re lucky enough to have Sitecore 8.1, the Explore Mode now lets you manually set campaigns. Otherwise yes, yo’re stuck with using separate browsers / incognito and such.

  3. Mohammad Chamanpara

    Hello Mark,

    It was a great deal of help and gave me a significant insight into the campaign triggering subject.
    Thank you so much.

Leave a Reply

Your email address will not be published. Required fields are marked *