Cross-Domain Tracking Part 2
BY Kai Reuther ON November 17, 2015 | IN Tutorials
This is a alt
Kai Reuther Headshot
Kai Reuther
Senior Digital Analytics Architect, EMEA. Kai has 10+ years experience specialising in helping clients build a data architecture that fits their business needs, paving the way from a nascent to a multi moment business model. Kai has exhaustive knowledge of Google Analytics, Google Tag Manager, Optimize, Google Ads, DV360, CM360 and SA360. He is also very proficient in all aspects of Salesforce, how connecting that platform to the GMP stack can drive excellent results. In short, he understands the details of the platforms as well as how they connect to build the most value to our clients. Kai is also GMP Certified.

Previously I explained what cross-domain tracking is and how it works. This post is more about the ‘how’ rather than the ‘what’ and ‘why’.

Cross-domain tracking using inline script

If you are not using GTM yet (what are you waiting for?!?!) and your GA tracking script is still hardcoded, it will look something like this:


GA Tracking Code


In order to enable cross-domain tracking, you will need to modify your tracking script on your primary domain with these additional parameters:


GA Cross-Domain Script


For your secondary domain (in this case you will need to do the same, but here you need to replace the line ‘ga(‘linker:autoLink’, [‘’] );’ with ‘ga(‘linker:autoLink’, [‘’] );

If you have multiple domains, you can list the domains in a comma separated list: ga(‘linker:autoLink’, [‘’, ‘’] );

Now let us take a look at what we have just added to our tracking script.

allowLinker’:true is there to tell the script to look out for the _ga cookie values in the url and grab them when they are present, this by the way has no merit on sub-domain tracking. ga(‘require’, ‘linker’); loads the GA cross-domain plugin and ga(‘linker:autoLink’, [‘’]); defines which domains to autoLink to.

Cross-Domain tracking using GTM

Using GTM, this process is very straightforward and quick to set up. Cross-domain tracking is set up using your Universal Analytics pageview tag. For this we need to look at the ‘More settings’ menu. Expanding this exposes a wealth of stuff we can tinker with. However for the purpose of setting up cross-domain tracking we will only focus on two of the 7 additional settings, these are ‘Fields to Set’ and ‘Cross-Domain Tracking’.

Within ‘Fields to Set’ we will add two fields. These are ‘allowLinker’ and ‘cookieDomain’. We are going to set our allowLinker to ‘true’ and let GA decide which is the best cookie domain to use by setting it to ‘auto’. Please see the below screenshot for reference.


GA fields to set for cross-domain tracking


Next we are going to take a look at ‘Cross-Domain Tracking’ further down the page. Here you will find 1 field that you need to fill out and two drop-down menus which are optional.


GA cross-domain tracking settings


Similar to what you saw in the previous example with the script where we talked about ‘ga(‘linker:autoLink’, [‘’] );’, we will be using the ‘Auto Link Domains’ field to tell our tag which domains we want to track as part of cross-domain. In the above screenshot I have stated that I want to maintain my original traffic source when navigating between and

‘Use Hash as Delimiter’ dictates whether the cookie values shall be appended to the url using either a query string or a url fragment.

‘Use Hash as Delimiter’ set to ‘False:’

‘Use Hash as Delimiter’ set to ‘True’:

Which one to use depends on a case by case basis. It really depends on how the website has been built. Query strings are used by default. If this breaks the site then use the url fragments. If neither work, you will need to liaise with the dev who has built the site in order to find a solution. Setting ‘Use Hash as Delimiter’ to true will not affect the usage of other url fragments or query strings.

‘Decorate Forms’ should be used when you have a form that does a cross-domain submission.

Once you have successfully configured your tag and tested it thoroughly, (especially on websites built on older platforms!) create a new version in GTM and publish the changes. The next thing you need to do is go into GA and add the second domain that you want to track to the referral exclusion list. This is found in the Admin section in the middle column under ‘Tracking Info > Referral Exclusion List’.


Referral Exclusion List


And this is how you implement cross-domain tracking. Using Google Tag Manager is definitely the quicker and easier option of the two. I hope this two parter helped you understand where, when and how to implement cross-domain tracking. If you get stuck or have any questions then don’t hesitate to get in touch.