29 Oct 2015
Reading time: 4 mins.
|
Difficulty:

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?

Cross Domain Tracking

You may consider using the same Google Analytics tracking code for every site. Regrettably, that is not enough. Google Analytics tracking system still uses cookies. Particularly,  the GA cookie is defined by the browser and the visited domain. As a result, even if the same UA is used,  the GA cookie will vary and a new session will be opened by default.  The only way to avoid this problem is to set up Analytics every time it jumps from one domain to another.

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.

Cookie domain Google Analytics Tag Manager

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):

Cross domain configuration options in Tag Manager

https://support.google.com/tagmanager/answer=en

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.

Google Tag Manager auto event tracking

Allow Linker: True - Auto event tracking - 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:

Decorate Link tag triggers

We must create as many Decorate Link Tag  triggers as possible. For example:

Link click domain triggers

It is highly advisable to create a Click URL Hostname variable in order to enhace Tag Manager triggers’ reliabilty .

Click URL Hostname variable - GTM

Decorate Link tag will be similar to this and include triggers for every possible domain variation via link.

Decorate Link UA Tag setup

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.

Auto link domains - Decorate forms true

 

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.

Subdomain tracking Google Tag Manager

Additionally, all Universal Analytics tags should include the following Cookie Configuration.

Cookie configuration UA tags

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:

  1. Exclude Referral Sources (Property Administration  – Universal Analytics): all the domains and subdomains to be measured together are excluded from the referrer category.
  2. Filter in order to show data in cross domain tracking correctly.