Skip to main content

Configuring Cross Domain Tracking With Google Tag Manager

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:

  1. A user browses for a hotel room on the website at Domain A
  2. Selecting a hotel room on Domain A sends users to a third-party booking engine site, Domain B
  3. 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 Fix
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.

google-analytics-referral-exclusion-list

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

cross-domain-tracking-setup

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.

decorate-form-trigger-gtm

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”.

form-decorater-gtm

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!

11 Comments

  • Thanks for the help!

  • HI ELI, Thanks for the post.
    What will happen if you have 2 separate GA account for those 2 sites and you want both GA record the same conversion type?
    Would you install a GA analytic script together with the shared GTM on each site?

  • Hi Eli,

    Thank you for the thorough explanation, I have a little different scenario

    If I am switching my domain on my website, I will be doing a 301 redirect slowly and monitor my analytics but DURING THE SWITCH should I be using one google analytics account and add two properties as I do not want to change my properties URL just yet but I do want to capture the data on the new site too, or should I create a separate google analytics account entirely and later delete the first one. I am moving from omeida.com.cn to omeidachinese.com, also adding an https to my new website. I want data for both websites WHILE SWITCHING before I move my analytics to the other one. please advise

    • In this case you can use one analytics code and create custom reports for each URL. Just segment by the ‘hostname’ to see individual site performance

  • Thank you for your information.
    We are implement GA on Magento platform and collect the e-commerce data by setting up the trigger by /checkout/onepage/success/
    which completed the payment from third-party payment gateway. But sometime, the customer didn’t click the URL back to our site after complete the payment. Such that we are miss out some revenue on GA report.

    So this cross-domain function can configure the trigger point on third-party gateway by complete payment URL?

    Norman

    • If your tag is present on the third party domain and you have set up cross-domain tracking properly, it should attribute in GA! Good luck

  • Awesome tutorial – been struggling with this very issue with a Travelclick client. Have you managed to get Ecommerce tracking to work as well? This part seems to still fail for us!

    • Travelclick’s team ended up configuring ecommerce tracking for us, it seems to work correctly. Contact their team about it for sure!

  • Hey Eli,

    I followed all your steps. Doesn’t seem to be working. My issue is double counting pages where an iFrame form is installed. Example is http://www.navigarecruiting.com/about-naviga-recruiting-executive-search/recruitment-markets/recruitment-atlanta/. The iframe is pointing to my forms at infusionsoft.com.

    Only thing I am concerned about is that I cannot add GTM code on the iFrame form page in total. I don’t have access to the header. I put the script for the body as a hidden field on the form.

    The rest, I believe I did everything you suggested including updating the GA tag in GTM, creating the link and form decorators, and updated the referral exclusion list.

    Do you have any suggestions on how to get this cross-domain scenario set up successfully?

    Thanks,
    Kevin

    • Hi Kevin,

      Sorry for missing this. Did you find a solution? It seems like you can use other forms that integrate with infusionsoft, such as contactform 7 or gravityforms. These forms would stay on your domain, meaning you would not need cross domain tracking at all.

      Cheers,
      Eli

Leave a Reply