#GTMTips: Cross-Domain Tracking With Multiple GA Trackers

How to setup cross-domain tracking to Google Analytics when you have more than one tracker running on the page.

To be fair, this tip isn’t just for Google Tag Manager but for regular old on-page Google Analytics as well. It’s one of those little things that’s corroding your data quality without you ever realizing it. Namely, this tip is about how to handle cross-domain tracking in situations where you are sending data to multiple Google Analytics properties on the same page.

It’s a very typical scenario - you have a “local” property, which tracks only the traffic of the current site, and then a “rollup” property, where you send data from all your organization’s websites. The rollup property would need cross-domain tracking enabled, since you want to track users across your organization’s many website domains.

Tip 56: Manage Cross-domain Tracking In Multi-Property Setups

The problem, in a nutshell, is that your cross-domain tracking property has the power to overwrite the value of the _ga cookie. It does this with the combination of the allowLinker: true field and a linker parameter in the URL of the page.

Since all of your trackers and tags, by default, use the _ga, it’s possible this is wreaking havoc on your data quality.

You see, when a URL is loaded with the linker parameter, such as when traffic from another domain to the current page is decorated with cross-domain linker parameters, any tracker on the page with allowLinker: true checks if the linker parameter is valid. If it is, the Client ID is grabbed from the linker parameter and used on the current page to replace the value of the _ga cookie.

Thus, if there already WAS a _ga cookie with a different Client ID, tough luck. It’s now overwritten with what was in the linker parameter.

This means that any user who used to have a Client ID of X in your GA tracking will now have a Client ID of Y, meaning they are effectively treated as completely different users.

Annoying, right?

Well, there’s a way to fix this. Basically, in all the trackers and tags that DO accept cross-domain tracking, you will need to use a different cookie name than _ga to store the Client ID! This way the cross-domain Client ID will not overwrite any pre-existing user data stored in the browser, but will be isolated in its own cookie where it will harm no one.

Here are the basic steps.

  1. In every single tag (GTM) or tracker (regular GA) that is not used for cross-domain tracking, make sure to either leave out the allowLinker field or set its value to false. This is very important.

  2. In every single tag (GTM) or tracker (regular GA) used for cross-domain tracking, make sure to set the cookieName field to something other than _ga, e.g. _rollupGa, and make sure to set the allowLinker field to true.

So in the end you should have two types of field configurations in your GA trackers and tags. One set has no cross-domain settings, no special cookie settings, and no allowLinker field set. The other set has a new cookie name and has the allowLinker field set to true. Here’s an example using regular, on-page GA:

// Regular GA tracker, uses _ga cookie
ga('create', 'UA-12345-1', {allowLinker: false});

// Rollup GA tracker
ga('create', 'UA-12345-2', {name: 'rollup', cookieName: '_rollupGa', allowLinker: true});

It’s important that you audit all your tags and trackers and take extra care to see that not a single one of your non-cross-domain tags has the allowLinker field set to true, and that every single one of your cross-domain tags has the cookieName field set to the custom cookie name.

There, I think I’ve repeated myself sufficiently to impress you with what you should do the next time you setup cross-domain tracking through GTM or on-page GA.

Good luck!