Overriding Google Analytics Campaign Parameters for Better Attribution

Two years ago I wrote an article about how to prevent transactional emails ruining your channel attribution in Google Analytics.

In this post I want to review my method of setting it up, and explain a better way.

A brief review of 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)
  • Email (if you’ve properly implemented UTM tracking)

The problem is that this new session is now misattributed to one of these channels, rather than the channel which drove the conversion in the first place.

For example, consider someone who visits the website via a PPC ad and registers for an account:

PPC -> Account Registration -> Registration Conversion

The initial unverified registration conversion is correctly attributed to the Paid Search channel. But our company requires people confirm their email address before we count them as a true conversion. So they are sent an ’email verification’ email containing a link back to the website.

The person clicks this link and lands on a page which verifies their email.

Verification Email -> Verify Email Page -> Verify Account Conversion

The Verify Account conversion will be misattributed to Referral or Email, rather than Paid Search (which it should be).


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.

Sadly analytics.js did away with this functionality.

So let’s bring it back…

Re-introducing nooverride

We’ll create a new parameter called nov (standing for No oVerride). When used in a link it will act exactly as utm_nooverride did.

First up, create a URL variable in Google Tag Manager called url_no_override. Set the Query Key to ‘nov’. This simply reads the query parameter out of the URL, if it exists.

URL variable in Google Tag Manager

Next, create a Custom JavaScript variable called ga_custom_task. Add the following code:

function() {
  return function(tracker) {
    if ({{url_no_override}}) {
      tracker.set('campaignSource', '');
      tracker.set('documentLocation', '');
      tracker.set('documentReferrer', '');

The code should be self explanatory, but here’s some help:

  • Line 2 returns a function which will be called by the customTask component of the Google Analytics library. Read more in the official docs.
  • Line 3 checks whether our variable has a truthy value or not. If it does, it means the nov URL parameter exists in the URL, and we should go ahead and ignore the referral information.
  • Lines 4-6 override the campaign source, plus document location and referrer. By setting them like this, the session will either go into the Direct channel, or the last referring campaign (up to 6 months).

Lines 4-6 should work due to flow Google Analytics goes through to determine how to attribute your session. The diagram below is from the official Google docs (here):

Google Analytics attribution flow

We want to get to the bottom left decision of ‘Existing campaign?’. To do this, campaignSource, documentLocation and documentReferrer must not exist. By setting them to an empty string in our GTM custom task, we achieve this.

Once complete, it should look like this:

GTM Custom Task

Finally, alter your Google Analytics Settings variable. Under the Fields to Set section, add a new row with Field Name customTask and Value {{ga_custom_task}}.

Google Analytics Campaign Override with Custom Task

How to use

To use this functionality, add the URL parameter nov=1 to all links back to your website in your transactional emails.

For example:




Now when someone clicks on the link their session will be attributed correctly.

Ed Brocklebank (aka Metric Mogul) is an analytics and digital marketing consultant. He helps business of all sizes become more data-driven through measurement, strategy and activation. He works as a Strategic Analytics Director at Jellyfish in London, as well as delivering training on behalf of Google and formerly General Assembly.