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

11

  1. Jerhico

    March 9, 2017

    Thanks for the help!

  2. Kelly

    July 6, 2017

    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?

    1. eli

      July 6, 2017

      Perhaps this thread will be most helpful
      http://www.simoahava.com/gtm-tips/cross-domain-tracking-with-multiple-ga-trackers/

  3. Omeida Chinese

    August 29, 2017

    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

    1. Navigator Multimedia Inc

      November 17, 2017

      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

  4. Norman

    November 28, 2017

    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

    1. Navigator Multimedia Inc

      December 1, 2017

      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

  5. Michelle

    January 4, 2018

    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!

    1. Navigator Multimedia Inc

      January 23, 2018

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

  6. Kevin Steffey

    July 26, 2018

    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

    1. Navigator Multimedia Inc

      September 12, 2018

      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

Related Posts

Kelowna SEO Company | Navigator Multimedia

The Navigator Multimedia team having a meeting in the office boardroom, ready to help our clients succeed with graphic design, web development, online marketing, and general digital marketing support..

30 Marketing Strategies for Small Businesses Learned from 30 Years in Digital Marketing

Here are 30 effective marketing strategies and marketing initiatives for small businesses in 2023-24.

Four people sit and stand around two laptops as they study SEO and digital marketing for their online business.

The Importance of SEO & Content Marketing in Digital Marketing (2023 Guide)

Own a business, work in sales, or manage a marketing department? This article explains the importance of SEO (search engine...

A pair of hands types an a Mac laptop computer while examining a Google Analytics report to prepare for the switch from Universal Analytics to GA4.

Google Analytics Is Updating from Universal Analytics To GA4

Here’s Navigator Multimedia’s Guide To Help You With The Switch Google Analytics is one of the most important tools for online marketing and analyzing website performance. As the way we navigate the web changes, Google Analytics needs to adapt accordingly....