Hands holding
Marketing
Sitecore Analytics

Unifying Sitecore and Google Analytics Campaign Tracking

Jan 21, 2020

When it comes to tracking marketing campaigns, many marketers' implementation story goes like this: by the time I started using the Sitecore Experience Platform I had already been using Google Analytics for a while. That means that they are familiar with Google Analytics' attribution model, reports, and URL parameters. Incorporating a new tool (Sitecore) into their process implies extra effort: first, learning their way around it and second, setting up the campaign in two places instead of one. Frequently, this results in marketers wondering if they should replace Google Analytics with Sitecore, or most likely, not using Sitecore Campaign Creator.

Using both tools, side by side is a very much recommended approach since in that way you will be able to:

  1. continue to use Google Analytics to analyze the performance of your campaigns against your historical data
  2. leverage the data gathered by Sitecore to personalize your visitor’s experience on your website and more efficiently drive them to conversion points

But what if you could achieve both while using Sitecore Campaign Creator?

At Oshyn we have implemented a Sitecore module that allows you to simply use Sitecore Campaign Creator to generate both Sitecore Campaign & UTM tracking parameters. Let's look at it...

The Precedent

Google Analytics

In Google Analytics you use UTM parameters to track your visitor's interactions with your campaigns. UTM parameters (sometimes called UTM codes) are specific text strings that you append to URLs. When you add UTM parameters to a URL, Google Analytics picks up the data in the code and records it with the page view. The resulting data is visible in Google Analytics reports.

There are 5 UTM codes you can use to track your campaigns in Google Analytics:

  1. Source = utm_source – Tracks the actual site where your visitors found your campaign URL. Eg. facebook, google or your newsletter.
  2. Medium = utm_medium – The channel where the traffic originated. Following the same example from above, you can pair the mentioned sources to mediums as follows facebook to social, google to organic, google to cost-per-click (cpc) and newsletter to email.
  3. Name = utm_campaign – Identifies and describes your campaign. This tag will allow you to aggregate traffic across channels. For example, your Christmas campaign might be generating lots of revenue, but you're running different versions of the campaign via email, video ads, and in-app ads. Then you use the campaign name as the tag that aggregates traffic coming from the different mediums and sources to compare the results to see where your marketing is most effective.
  4. Term = utm_term – You’ll use this tag mainly for tracking your keywords during a paid AdWords campaign. You can also use it in your display ad campaigns to identify aspects of your audience.
  5. Content = utm_content – If you’re A/B testing ads, then you can use this parameter to specify the version of your ad. You can also use it to differentiate links that point to the same URL.

To facilitate the generation of a campaign link most marketers leverage Google's Campaign URL Builder. A form where you enter the values for the URL and each parameter, and it generates the parameterized URL for you to copy and paste.

Google Analytics Campaign URL Builder

Google Analytics Campaign URL Builder

Sitecore

In Sitecore, you use the Campaign Creator to create campaign activities. Sitecore campaign activities have many configuration options to help you keep track of your efforts. While setting up a campaign you will use:

  • Campaign groups - Parent groupings contain multiple campaign activities across different channels.
  • Channel - Sitecore ships with a large list of online and offline channels. You can define a channel per campaign activity.
  • Asset - Media items classified as marketing assets can be associated with your campaign activities.
  • Campaign facets - Sitecore provides seven by default. These allow you to create a custom taxonomy to tag your campaign activities so that you can identify and track relationships between them. Facets are meant to describe aspects of your campaigns that are appropriate for your company and industry. Custom factors such as campaign iteration, campaign geography, campaign target audience or business unit/branch can be defined as campaign facets.
Sitecore campaign activity

Sitecore Campaign Activity Configuration

When you create a campaign activity, the Campaign Creator generates a campaign tracking code. Appending this code to any URL included in your campaign content (email, add, etc.) will allow Sitecore to track the website traffic generated by your campaign.

Sitecore campaign link

Sitecore Campaign Link

Our Approach

The main reason to develop this functionality is to unify UTM and Sitecore tagging. We want to track our marketing campaigns in Google Analytics and Sitecore without defining our campaign attributes twice.

Our solution allows you to manage all tags in Sitecore. Campaign tags are managed as taxonomy items in the Marketing Control Panel.

The values you define in your Sitecore campaign activities are mapped to the Google Analytics UTM parameters as follows:

  1. Channel = utm_source
  2. Channel group = utm_medium
    Marketers have the ability to modify a long list of existing channels and defining new ones. The taxonomy is hierarchically defined as:
    - channel type (e.g. Online)
    - channel group (e.g. Email)
    - channel (e.g Email newsletter)

    Sitecore channel taxonomy

    Sitecore channel taxonomy

    This taxonomy structure is reflected in the Campaign Creator selection fields as slash-separated items

    Sitecore campaign field

    The following image shows what our mapping looks like

    Sitecore campaign field
  3. Campaign group = utm_campaign

    Sitecore campaign field
  4. Campaign facet 1 = utm_term
    We changed the facet display name to "Term" and it is intended to be used in cases where you want to track the keyword used in a paid add.

    Sitecore campaign field
  5. Campaign facet 2 = utm_content
    Similar to facet 1, we changed the facet display name to "Content". It is intended to be used in cases where you want to track the version of the content displayed to a user that is part of a campaign with A/B testing.
    Sitecore campaign field

Additionally, we renamed the "Campaign facet 3" to "Push to data layer" and defined Yes and No as its options. In the end, Sitecore will use the values you define in the fields described above to generate the query string to be added to your campaign links

  1. If Yes is selected, only the Sitecore campaign code will be shown in the Campaign link field
  2. If No is selected, then the Campaign link field must also include the UTM parameters

Some additional rules:

  1. If a field is left empty it must be omitted on the query string shown to the user
  2. Any spaces in the values entered by the editor for UTM parameters must be replaced with -
  3. Query string parameters must be lowercase

Here is an example of the result obtained when an activity is configured not to push the data to the data layer. In this case, Sitecore generates for you all the parameters that must be added to your campaign links so that user's interactions are tracked in Sitecore and Google Analytics.

Sitecore campaign activity

Parameters entered by the editor

Sitecore campaign link

Query string built by the system

Push Campaign to the Data Layer

It is possible to implement the tracking of your marketing campaigns through Google Tag Manager (GTM). GTM allows us to track campaign activities without adding the UTM parameters to our links. In this case, we use the data layer. "A data layer is a JavaScript object that is used to pass information from your website to your Tag Manager container".

When you select "Yes" in the Campaign Creator you are telling our Sitecore to push the campaign attributes to the data layer instead of adding them to the Campaign link.

Sitecore campaign activity field

With this configuration done you only need to add the Sitecore campaign code as a parameter to your campaign links.

Sitecore campaign activity field

Our module will add the data layer object to the head tag of any page in which the URL has the sc_camp parameter on it.

dataLayer = [{‘scCampaignId’: {{Campaign id}},
            ‘scCampaignName’: {{Campaign name}},
            ‘scCampaignChannel’: {{Campaign channel}},
            ‘scCampaignMedium’: {{Campaign medium}},
            ‘scCampaignGroup’: {{Campaign group}},
            ‘scCampaignTerm’: {{Campaign term}},
            ‘scCampaignContent’: {{Campaign content}}}];

The variables values (e.g. {{Campaign channel}}) will be replaced with your selection for that attribute in the Campaign Creator.

Sitecore campaign activity

Campaign configuration in Sitecore

Website code inspected

Data layer object on a web page with a campaign link

In a future post, I'll describe how to grab the values from the data layer to push them to Google Analytics using GTM. Stay tuned...

Hide URL Parameters

In Sitecore, it is also possible to omit the URL parameter and yet, track your campaign interactions. In cases where you have a landing page for your campaign activity, Sitecore gives you the option of associating the two. This is particularly useful for the campaigns you run over offline channels such as direct-mail or billboards.

When you associate a landing page to a campaign in Sitecore our module pushes the campaign attributes to the data layer as previously described. So if you have a landing page for your campaign activity it makes it possible to track it in Sitecore and Google Analytics without the need for parameters in your links.

Sitecore campaign associated to landing page

Linking Sitecore Page to Campaign Activity

Final Thoughts

This approach allows you to manage your campaign tags taxonomy in Sitecore. Being able to hierarchically organize your taxonomy in the Marketing Control Panel and reuse the tags over time will make your life easier. It certainly is an improvement compared to using a spreadsheet to keep track of the names, sources, and mediums you have used to define your activities. Remember that consistency matters, Google Analytics is case sensitive. If your tags for different campaign activities don't match, they won't be aggregated in reports.

Using Sitecore to track your marketing campaigns unlocks endless possibilities to optimize your customer journeys. You will be able to use campaign interactions to add engagement value points to your visitors profiles; use campaign data to fuel for personalized experiences, or to trigger automated responses from your website.

Don't hesitate to reach out if you'd like to give it a try. Use the form below to send us a message, we will be pleased to answer your questions.

A thank you note: Kudos to Byron Calisto for standing up to the challenge and implementing this module. He will be releasing it to the marketplace soon :)