In this tutorial, we will take a look at how to implement utm_nooverride in Universal Analytics.
Reference #
The problem #
If you send transactional emails (for example, an order confirmation email or email verification email) with links back to your website, when someone clicks that link a new session will start and will be attributed to one of the following channels:
- Referral (because lots of people use online email services like gmail.com)
- Direct (because offline email clients such as Outlook and Mac Mail will launch a web browser and go direct to the URL; or any link in a pdf or file attached in the email that direct to you website)
- Email (if you’ve properly implemented UTM tracking)
Imagine this scenario.
Users arrive on your website via a PPC ad and apply for a quote.
Your systems emails them a quote with a link in email that they can click on to buy.
The users click this link and lands back to the website and convert the quote.
When you look at the Google Analytics data, the conversions have been attributed to Referral or Direct or Email, rather than Paid Search (which it should be).
utm_nooverride in ga.js #
The old version of Google Analytics (ga.js) had a URL parameter called utm_nooverride. By adding this to your external links, Google Analytics would ignore whatever channel the person was from, and instead attribute the session to the previous one.
mydomain.com?utm_nooverride=1
Sadly analytics.js did away with this functionality.
So let’s get the “utm_override” function working again.
utm_nooverride in ga UA #
Using Google Tag Manager, we are going to create our own parameter that has exactly the same effect.
Step 1: URL variable
Create a URL variable (I called u.utm_nooverride)
Set the Query Key to
utm_nooverride
Step 2: custom JavaScript variable
Create a custom JavaScript variable (I called u.campaignSource)
Enter the following code:
function() { if (typeof({{u.utm_nooverride}}) !== 'undefined') { return '(direct)'; } return null; }
Open your Universal Analytics tag
Under the “Fields to Set” section, add a new row
Set Field Name
campaignSource
and Value{{u.campaignSource}}
.
Step 3: alter your Google Analytics Settings variable
Conclusion #
What does this do?
When the utm_nooverride
param is set in the URL, the u.campaignSource
variable can only be two values:
null
direct
If the value is null then it will be ignored by GA and the campaignSource
field won’t be set.
Otherwise, it will be set to ‘direct’ and our campaign information won’t be overridden.