How to setup cross domain tracking on Google Analytics using Tag Manager
Imagine you have several related sites. You are interested in using Google Analytics to track and measure a complete user session across them regardless of any domain switch. What can you do?
There are three possible scenarios:
1. Domain and subdomain tracking on Google Analytics
Domain and subdomain tracking for a single Google Analytics property can be easily set up on Google Tag Manager. You just need to configure an additonal field on Universal Analytics Tags: More settings → Fields to set → Field Name: cookieDomain. Then you will be required to fill the field with the name of the main (top-level) domain. In other words: given domain.com and sub.domain.com, domain.com is to be written in the mentioned field.
2. Cross Domain Tracking on Google Analytics
There are two options on Google Tag Manager (GTM) to set up cross domain tracking for the same web property (several top-level domains. I.e. domain1.com, domain2.com, domain3.com):
Link/Form decoration tag-based Cross domain tracking –also known as Auto Event Tracking– is more complex, manual and flexible. In contrast, Auto Link Domain method is easier and more automatic but far less flexible. Whereas Auto Event Tracking can be enabled on Universal and Classic Analytics, Auto Link Domain only works on Universal Analytics.
2.1 AUTO EVENT TRACKING ON GTM
Google Analytics _set Allow Linker () method must be used in order to enable Auto Event cross domain tracking. In this sense, you are required to trigger Allow Linker – True option at every Universal Analytics Tag set up in GTM.
Besides, GTM provides two auto event cross domain tracking-oriented tags within Google Analytics. Their set up is thoroughly explained in the following links.
There are some aspects to be considered:
With regard to Decorating Link Tags triggers follow this pattern:
We must create as many Decorate Link Tag triggers as possible. For example:
It is highly advisable to create a Click URL Hostname variable in order to enhace Tag Manager triggers’ reliabilty .
Decorate Link tag will be similar to this and include triggers for every possible domain variation via link.
Provided that we opt for using # for link decoration and discarding query parameters , Use Hash as Delimiter must be changed to True.
2.2 AUTO LINK TRACKING ON GTM
It is necessary to set up at least two fields in all the tags involved in cross domain tracking (Universal Analytics Tags within Tag Manager):
a) Auto Link Domain: enter in this field the top-level domains you would like to include in a Google Analytics property.
b) Allow Linker: change the field to True in order to enable cross domain tracking.
c) Alternative set ups:
- Use Hash as Delimiter: opt for this alternative when you wish to decorate links using Hash (#) instead of query parameters (?). True: # // False: ?.
- Provided that there is a form whose action takes users from a website to another, Decorate Forms: True must be enabled.
3. Cross Domain Tracking
This is a quite complex situation. It demands to track top-level domains and some of their subdomains. In this case, cookies’ domains (_setDomainName) must be correctly defined on each tag, matching their counterpart on Google Tag Manager (Cookie Domain), as we mentioned above (see Part 1) . As there are several top-level domains, a lookup table must be created in order to assign correctly each subdomain to their top-level subdomain.
Additionally, all Universal Analytics tags should include the following Cookie Configuration.
This configuration above is valid regardless of the cross domain tracking method used in Google Tag Manager.
CROSS DOMAIN SET UP IN GOOGLE ANALYTICS
Adjustments required to enable Cross Domain Tracking in GA:
- Exclude Referral Sources (Property Administration – Universal Analytics): all the domains and subdomains to be measured together are excluded from the referrer category.
- Filter in order to show data in cross domain tracking correctly.