Cross domain tracking with Google Tag Manager (GTM) is an excellent way to ensure you don’t lose Google Analytics data when users move between your different domains during the same session. This post will cover the set up steps, with relevant screenshots to make sure your implementation is a success. If any part of this post is unclear, feel free to leave a comment.
There are two methods to track cross-domain activity: Using 1. Auto Link Domains or 2. Form/Link Decorator Tags. We’re using 2 here.
The Problem Scenario
We needed to configure cross domain tracking for a hotel client and decided to use Google Tag Manager to do it with relative ease. Our problem scenario went like this:
- A user browses for a hotel room on the website at Domain A
- Selecting a hotel room on Domain A sends users to a third-party booking engine site, Domain B
- Source / Medium data in Google Analytics is dropped once the user moves to Domain B, becoming (direct) / (none). This happens even though Google Analytics was installed on both domains, argh!
Without source/medium data, we’re unable to properly track our marketing efforts.
Our article hopes to explain how we solved cross-domain tracking with Google Tag Manager, with these additional factors to watch out for:
- Form submit data needs to be carried from Domain A to Domain B
- Domain B uses multiple subdomains
- Domain A and Domain B use different containers
1. Install Google Tag Manager on both domains
Google Tag Manager (GTM) makes it easy to consolidate and manage multiple tags within one “container”, without having to modify site code.
Open a container and install the code on your sites. At the same time, be sure to remove your existing GA tag, because now it will be contained within GTM.
I recommend installing Google Tag Assistant for Chrome, it’s great for quickly checking if website tags are firing properly.
2. In Google Analytics, add both domains to the referral exclusion list
Referral exclusions tells Google Analytics to record sessions as if they are from the same website, even though we’re using separate domains. The primary domain will be listed there by default.
Note: travelclick.com and ihotelier.com use a few different sub-domains (ie: booking.ihotelier.com and reservations.ihotelier.com). By adding the root domain we are covering any and all sub-domains. If you are targeting ONLY a specific sub-domain, include the subdomain(s) instead of the root.
Note 2: Our referral exclusion list for this property also now includes travelclick.com, their new booking engine site.
3. Modify your Universal Analytics Page View Tags in Google Tag Manager
This is what needs modified on your Universal Analytics tag.
allowLinker : true
cookieDomain : auto
Auto Link Domains : podollanhotels.com,travelclick.com,ihotelier.com
Note: This tag by default will fire on ‘All Pages’
Note 2: We’re using two separate GTM Containers because of how Travelclick configured their site. Make sure each Page View tag in each container you’re using has the same configuration.
4. Set Up Link Decorator
Create a trigger and choose Just Links as the trigger type. Enable this tag for when the url contains Domain A and for when click target contains Domain B, Domain C, etc
Next, Add a Google Analytics tag to your GTM container. Select Track Type “Decorate Link”. Select the click trigger you just created under “Triggering”.
5. Set Up Form Decorator
If your site submits a form to another domain, we also need to decorate forms with Google Analytics cookie data.
Create a trigger that uses forms. You may have to use different settings than this depending on your form setup. I used our form’s ID to ensure only this form decorates links.
Next, Add a Google Analytics tag to your GTM container. Select Track Type “Decorate Form”. Set the trigger to the form trigger you just created under “triggering”.
6. Confirm cross domain tracking setup in Preview Mode
Using Tag Manager’s Preview and Debug mode, you can test that your tracking is working correctly.
That’s it for cross domain tracking setup. As your website traffic moves to your 3rd party booking engine you will be able to see attribution from all traffic sources. Let us know if you have any questions below!