What is Cross Domain tracking?
We refer to cross-domain tracking when we need to describe the act of tracking multiple domains. However, we also use this term to describe tracking different subdomains or pretty much any two, three or multiple entities in a single Google Analytics property.
Cross-domain tracking is considered an advanced concept that can be complex and quite difficult to troubleshoot. However, as the majority of Google Analytics users track just one domain name at a time, it’s a fairly unusual implementation.
As we mentioned before, Google Analytics cross domain tracking could be useful when we need to setup tracking on multiple sub-domains, or even different domains and need to see data from all sites in one view. For example, we can set it up to understand our customer behavior across both our ecommerce site and the 3rd party shopping cart site.
Cross Domain Tracking Example
So, for example, we have two related websites which need tracking: examplestore.com and example.com. As you probably guessed, the first domain is our ecommerce store which is a child of example.com. We would like to track and understand the user experience across them both.
Normally, each domain will have a separate Google Analytics setup because they are two different entities. A cross domain tracking (sometimes is called site linking) is when you “connect” them together, so you can view the Google Analytics reports for both of them holistically.
Or what if we have a subdomain for a tool we built and sits on widget1.example.com and we need to track the traffic from it? Here, we’d need subdomain tracking, which we will dive into next.
Correctly Tracking Subdomains In Google Analytics
There are two required steps to track user behavior across different subdomains as a single session in Universal Analytics. First setting helps to connect sessions from a single user and the second one helps us attribute data to the same session.
To implement these two requirements, we need to:
- Set the Cookie Domain
- Update Referral Exclusion List
Step 1: Set the Cookie Domain
If we use the Google Analytics snippet in our code, it’s likely that the Cookie Domain is already set to ‘auto.’ This setting will allow hits from our subdomain to share the same first-party cookie, therefore, will allow Google Analytics to understand that those hits came from the same user. Below is an example of GA’s recommended snippet. You can check this by going to any page on your site, right clicking to ‘View Source Code’ and looking for a snippet similar to the one below.

If we are using Google Tag Manager, the first step setup is a little bit different. We need to update our Google Analytics tag by adding the following instruction:

If we have multiple subdomains, please remember that we need to have same implementation on all the subdomains that need to be tracked together.
Step 2: Update Referral Exclusion List
In most cases, this setup is probably already in place in your Google Analytics account. To check this, go to the Admin Panel in GA and check if the root domain has been added to the Referral Exclusion List.
This step is important because when the user moves from one domain (or subdomain) to another, the Universal Analytics code will send referrer information to Google Analytics. When Google Analytics sees a new referrer that is different from original source/medium information, it will start a new session with the new traffic source information. The Referral Exclusion List prevents this from happening and will let the original session continue.
To understand better why these steps are important in subdomain cross tracking, let’s use the previous example:
One of our users arrives at example.com through a Facebook post and clicks to learn more about widgets: example.com/widgets. Next, they want to know more about our tool which lives at: widget1.example.com/info. They move on to find out how much it costs on widget1.example.com/pricing. After revising the pricing, they go back to see the other widgets: example.com/widgets
There are 3 ways in which we can see this user journey in our Google Analytics. All 3 cases depend on whether we setup subdomain tracking in GA correctly or not:

Case 1: Cookie Domain not set to auto, no referral exclusions – 2 Users, 3 Sessions
Case 2: Cookie Domain set to auto, no referral exclusions – 1 Users, 3 Sessions
Case 3: Cookie Domain set to auto, example.com set as referral exclusions – 1 Users, 1 Session
Now, that we covered the easiest scenario: subdomain cross tracking, let’s dive into how to set up Google Analytics cross domain tracking for separate domains.
How to Set Up Cross Domain Tracking
As we saw before, GA needs to recognise a user that moves from one domain to another as a single user and usually this is done using a client ID which is typically stored in the GA cookie. This first party cookie is used to stitch all the hits together into a single session. However, the problem arises because first party cookies cannot be shared across different root domains.
So, how can we pass along the client ID as the user moves between different domains? Well, the answer is quite simple: we need to include it in a parameter which we’ll add to the URL that a user clicks on and tell GA to follow it all the way.
There are two different approaches to this, which are based on whether you’re using hard-coded (i.e. snippet-based) GA or a GTM-based implementation.
Approach 1: Hard-coded GA snippet
- Set up one property in Google Analytics account and use the same tracking code and ID for all our domains (example1.com, example2.com)
- Edit the GA tracking code snippet by adding the following lines (bolded):
ga(‘create’, ‘UA-XXXXXXX-X’, ‘auto’, {‘allowLinker’: true});
ga(‘require’, ‘linker’);
ga(‘linker:autoLink’, [‘example2.com’] );
Of course, you’ll use your own Tracking ID and domains in your own implementation.
- Now, we need to edit the GA tracking code snippet on the second domain by adding the same lines as before – only difference is that we change example2.com with example1.com:
ga(‘create’, ‘UA-XXXXXXX-X’, ‘auto’, {‘allowLinker’: true});
ga(‘require’, ‘linker’);
ga(‘linker:autoLink’, [‘example1.com’] );
- Set up referral exclusions and filtered views.
Approach 2: GTM implementation
For this approach, we’re going to focus on a scenario where we’re using standard GTM-based implementations of the modern Universal Analytics syntax on both sites.
- Create a new ’Constant’ variable, containing a comma-separated list of the domains which are part of our cross-domain setup. In our example, it will look like this: example1.com, example2.com.

Note: It’s also important to remember that specifying a domain in this list will mean the client ID appended doesn’t just to link to that hostname, but to its subdomains too. To enable the plugin for a specific subdomain (e.g. myshop.example.com rather than example.com), enter the subdomain in this list rather than the root domain.
- Add your new Variable to your Google Analytics Pageview tag. Then head to Cross Domain Tracking and set the Auto Links Domains field to use your new variable.

- Then open Fields to Set and add a new field called allowLinker and set it to true.

- And as before, set up referral exclusions and filtered views. Keep in mind, this part is important because if we don’t set up exclusions, we’ll get “self-referrals” – a set of duplicate sessions when users jump back and forth between our properties.
After we implement cross domain tracking, we need to make sure everything is working as it should. The best way to do this is to double check if the hits are assigned properly by using Google Analytics Debugger Chrome extension.
This is a very useful tool not only for this case, but for any scenarios where you need to troubleshoot your GA installation or any tracking implementation. We are going to cover how to install and the benefits of using this tool in a future post.
For the moment, let’s head over to our first domain (example1.com, in our case). Using Dev Tools > Console we make a note of our client ID and tracking ID. Now, we need to go to our second domain (example2.com) and check if the client ID and tracking ID are matching.
Another important aspect, which is often overlooked, is the way we report our traffic when we use cross domain tracking. Given that the page dimension in GA only includes the path, and not the hostname / domain, we might want to set up an advanced filter to prepend the hostname to the URI.
We need to remember that these filters will not take effect retroactively, and so both versions of URLs will appear in our future reports. Therefore, we might want to consider setting up a new view moving forward.
So, why do we need Google Analytics cross domain tracking?
The purpose of using cross domain tracking is centralising data from multiple entities and to give you a more holistic view. Centralisation of data is important for gaining a deeper understanding of our customers’ behaviour. The more fractured your data sources are, the less holistic your marketing data will be. Therefore, cross domain tracking is one of the ways to consolidate your marketing data and inform your future business strategy.
If you are looking for Google Analytics consultants to assist you with your set up, feel free to reach out to us to see how we can help!