Google Analytics cross domain tracking with Google Tag Manager

Simple guide to setup cross domain tracking with GTM

Let us start with why you might need to use GA cross domain tracking with GTM.

In the main a single brand website is hosted across a single domain or a toplevel domain (TLD) with subdomains of this TLD used to manage subsections of the website.

As an example you might have blog.brandx.co.uk and shop.brandx.co.uk both residing on the TLD brandx.co.uk. For a single brand this is best solution, maintaining a coherent visual journey and brand experience for users as they browse and engage with your web content.

If this is your site then cross domain tracking isnt required, behavior across TLD and subdomains are measured by default providing you have left the cookie domain as ‘auto’ in GTM. You can also state the Top level domain for the same result.

If your customer journey is more complex than this, perhaps your brochure content is seperated from transactional content by domain but the customer flow requires you bridge the gap. In this scenarion you are going to  have to let GA know the session requires a hand over from domain x to domain y.

The number one requirement for cross domain logic is to being able to measure an end to end customer view on perforformance in order to attribute marketing activity (and cost) to the transactional activity b that a sales, booking or lead.

Step 1 Google Analytics preparation for cross domain tracking

You will need to update the referral exclusion rule in the GA property to include the domains you wish to measure under the cross domain property. This is done to avoid the respective domains from apearing as a source of traffic within the channel referral reports.

 

Add a filter to the reporting view to expose the domain name in the content reporting (see below). This is required so that you are able to differentiate between content that shares a common file path (e.g. dom1/ and dom2/ homepages with report a ‘/’ by defaul in you content, landing page and exit page reports).

 

To expose the hostname, navigate to the admin section of GA > View > Filters > Add Filter. Use the following settings:

Filter type: Custom filter > Advanced

Field A ? Extract A: Hostname = (.*)

Field B ? Extract B: Request URI = (.*)

Output to ? Constructor: Request URL = $A1$B1

Check the boxes: Field A Required, and Override Output Field

Step 2 GTM container setup for cross domain tracking

First up you will need to configure your Google Analytics Settings Variable. If don’t already use a setting variable go to variables>new User-defined Variable.

Provide a name in this case I used ‘Global GA Settings’.

Select the variable type as  ‘Google Analytics Settings’ and input your GA tracking ID that want to use. (You can use a lookup table to manage multiple environments)

Expand More Settings > Fields to Set, and set Field Name to “allowLinker” and Value “true.”

Next, expand Cross Domain Tracking, enter a comma-separated list of the domains you wish to include in cross-domain tracking.

Finally you will want to add the settings variable to your GA tags, starting with the main pageview tag.

Final step will be to publish and double check your tags are firing as expected. Make sure to remove any legacy tags as this can create a conflict with the cross domain logic.

If you have any questions or would like to discuss you own website measurement strategy get in touch.