Saturday . 20 Apr. 2024

Google Analytics Cross Domain Tracking with Google Tag Manager.

Google Analytics Cross Domain Tracking with Google Tag Manager.

In this article, we are going to discuss Cross-Domain Tracking with Google Tag Manager.

Most people find it difficult to set up cross-domain tracking functionality correctly on their website. There are some confusing aspects of cross-domain tracking but they can be resolved by understanding the concept behind them. To track multiple domains, you will need to make some changes to your tracking code. The good news is, Google Tag Manager (GTM) has made this process very simple. First of all, let's look something about cross-domain tracking.

Cross-Domain Tracking

Cross-domain tracking is the process of analyzing visitors of multiple sites in a single analytics view. You can report traffic of multiple websites as a single big website by implementing cross-domain tracking.

First Party cookie called _ga is used by Google Analytics ( Universal Analytics) for tracking purpose and can easily be done by setting cookie domain settings in GTM to auto. This "_ga" cookie is able to store information about the visitors.

But this first-party cookie cannot share this information with other domains. In this situation, cross-domain tracking comes to play. We should instruct it to share the values of the first site cookie with a second site cookie.

Before getting started

 You are not tracking cross-domain if you are trying to track users across various subsection of a single domain such as, or

In this case, you are trying to track subdomains and the perfect way to do this is to add " cookieDomain" under Field Name and set value " auto" in the Value section.

This setting instructs the tracker to make the cookie available to all of the subdomains.

Cross-Domain Tracking with Google Tag Manager

1. Create auto-link domains variable

First, you should create a constant variable. Configure variable with separation of a comma ( This is the list of all domains that you want to track in your property). 

Enter just the hostname if you want to track links to all subdomains of a domain

         For example for or enter only

Enter the full hostname if you want to track links to just one specific subdomain of an external domain.

Auto Link DomainsSource:

2. In your Page View Tag, add Auto Link Domains

Now, your job is to enable cross-domain tracking in your " Page View" tag. You will need to open the Universal Analytics Page View Tag in GTM to do this. Click " More settings" in the Configure Tag section and enter " Auto Link Domain" in the Auto Link Domain field.

Now any links that point to those domains are identified by Google Analytics for tracking users cross-domain.

Configure Tag's auto link domain sectionSource:

3. Add allowLinker in Fields to Set

You should make this setup to allow Google Analytics know which links to decorate when it sees in page path. Go to Fields to Set and expand it. Now add allowLinker into the " Field Name" and true in the " Value section.

You are almost done but don't hurry to publish it as you have one another step to accomplish.

Allow LinkerSource:

4. Update your Referral Exclusion List.

Referral Exclusion lists are the lists of domain names which are treated as traffic by Google Analytics instead of referrals. Google Analytics rewrites their sources information to be direct or none when users visit your website from a domain. Google Analytics will ignore the new referring information if users already have a session that has not expired.

Your cross-domain tracking won't work well if you don't add all of the domains that you had set in Auto Link Domains variable into referral exclusion lists.

To do this open " Admin" panel and select " Tracking info" from PROPERTY section. Select the " Referral Exclusion List" and click "Add Referral Exclusion". Now, enter all the hostnames that you like to exclude.

Referral exclusion listSource:

5. Test

Now, we need to test whether or not our cross-domain tracking is configured properly. Under " Page View" tag go to " Advanced Option" and set " Use Debug Version" into {{Debug Mode}} and click save.

Debug modeSource:

Now, click the " Preview" button and go to your home page to clear cookies. Reload your home page with special source and medium campaign parameters.

For example:

click on the link on any of your other domains and look for a bunch of extra parameters attached to the link( URL bar) when the page loads.


Test one:

You should see some extra parameters attached to the link on clicking to one of you auto-linked domains. If not go and check your Auto Link Domain settings.

We can also see the extra Debug with the help of developer tools in our browser

Simply click ( Crtl+Shift+K) on windows and CMD + AlT +K on a MAC to open developer tools console on your browser. You should see " Loaded Linker parameter: number strings".

Test two:

Check if you have set " allowLinker" parameter to true if you do not see the above line in the code. Just clear your cookie and close the page.

Next day go to Analytics and create Advanced segment to only show Users with Source cd_test. Now, you will see a single user with a single session and two page views.


Follow the above methods carefully for cross-domain tracking with Google Tag Manager.

Readers Comment