Cross-Domain Tracking With Google Tag Manager: A Simple Guide

cross-domian tracking google tag manager
POST
Author's Headshot
By Sarah Burke
Share

Cross-domain tracking can make your life a lot simpler if you find yourself having to analyze Google Analytics data from two different sites.

It allows you to capture the full user journey from the moment they land on one domain even if they continue off to another. 

And, if you love clean, accurate Google Analytics data as much as I do, it ensures your data is organized and ready for analysis. 

But setting up cross-domain tracking? Not always a simple process.

In this article, I’ll attempt to make it simple for you with easy-to-follow steps for how to set up cross-domain tracking with Google Tag Manager and Google Analytics. 

Note: Setting up cross-domain tracking can range from very simple to very complex. This article covers how to set up cross-domain tracking where a typical user journey involves clicks back and forth between multiple domains. In my examples, I’ll be referring to one domain as “siteA” and the other domain as “siteB”. If your setup is more complex than this, custom configuration may be required.

In this article we’ll cover:

Why Set Up Cross-Domain Tracking?

As mentioned above, cross-domain tracking is the only way to capture the full user journey across multiple sites.

Still need convincing? Check out these added benefits:

Avoid inflating data

Without cross-domain tracking implemented, a new session is initiated when the user crosses domains. That means a single user is counted twice, inflating your user and session data.

When cross-domain tracking is implemented, clicking off to the other domain will no longer trigger a new session. Each user can pass back and forth between domains as a single user.

Maintain accurate attribution

When cross-domain tracking is not implemented and a user clicks off to siteB from siteA, the original source/medium that brought them to siteA is lost. Depending on how your domains are set up, the source/medium will either be reported as a referral from siteA or direct traffic.

So, if you do not have cross-domain tracking or if it’s implemented improperly, you’ll see high amounts of self-referral traffic or direct traffic in your reporting.

Once cross-domain tracking is set up, this issue is solved and the original source/medium will be maintained when users click off to the other domain, keeping your reporting accurate.

When Should Cross-Domain Tracking Be Used?

Cross-domain tracking should be set up when you want to track users across multiple domains without triggering a new session.

This means that users can pass from one site to another maintaining the same clientID and a single user journey.

There are some instances when cross-domain tracking is not necessary, including having secure and non-secure versions of a website (HTTP and HTTPS) or www and non-www versions. These scenarios require no additional work -  Google Analytics will automatically capture all versions of these in a single property.

Is cross-domain tracking necessary for subdomains?

The full cross-domain tracking that we’re covering in this article is not necessary to track traffic to subdomains. It’s only necessary when tracking two completely different domains. 

However, there may be some additional setup required to track subdomains depending on how you’re firing Google Analytics in Google Tag Manager.

If you’re using the Google Analytics variable (which I recommend): there should not be any additional setup required, but it’s worth double-checking. The Cookie Domain within the variable should be set to “auto” as shown here:

The variable is automatically created with this set so it’s likely that it’s good to go.

But, again, I would give it a double-check since someone may have cleared it out at some point or set it up differently if the variable already existed in your container.

If you’re using the Google Analytics tag: you will need to set the Cookie Domain in the tag as it is not done by default here. 

Enable the overriding settings in the tag and set a new field as follows:

If you came to this article to track traffic to a subdomain, you’re all set! If you still need to track two separate domains, read on.

How To Set Up Cross-Domain Tracking

Google Tag Manager Configuration

  1. Install the appropriate GTM container on both domains. They can be the same or different.
  1. Fire the Google Analytics code via each GTM container. It’s very important to note that both domains need to send data into the same Google Analytics property in order for cross-domain tracking to work.

I generally recommend firing Google Analytics as a variable for the easiest management moving forward. However, the set up will be just about the same if you chose to use the Google Analytics tag instead.

  1. Adjust the settings in your Google Analytics variable or tag

If you’re using the Google Analytics variable: 

  1. Make sure that the Cookie Domain is set to “auto”. This is the default setting when creating a new Google Analytics variable so it’s likely already set. But, if your variable was already existing, it’s worth checking that it’s still there.
  2. Set a new field to “allowLinker” with a value of “true”
  1. Under Cross Domain Tracking, fill in the Auto Link Domains list with a comma-separated list of domains. Include all domains that send traffic to another domain. That means if there are links to siteB on siteA as well as links to siteA on siteB, both sitea.com and siteb.com should be included in the list. 
  1. If you’re using two different GTM containers, complete this setup in both.

If you’re using the Google Analytics tag:

  1. Check the box to enable overriding settings in the tag 
  2. Set a new field to “cookieDomain” with a value of “auto”
  3. Set another new field to “allowLinker” with a value of “true”
  1. Under Cross Domain Tracking, fill in the Auto Link Domains list with a comma-separated list of domains. Include all domains that send traffic to another domain. That means if there are links to siteB on siteA as well as links to siteA on siteB, both sitea.com and siteb.com should be included in the list. 
  1. If you’re using two different GTM containers, complete this setup in both.

Google Analytics Configuration

The only necessary step to complete in Google Analytics to get your cross-domain tracking up and running is to add your auto linked domains to the referral exclusion list in your Google Analytics view.

How To Add Domains To The Referral Exclusion List

  1. Open up the Google Analytics view that you’ll be using for cross-domain reporting
  2. Go To Admin in the left-hand menu
  3. Under Tracking Info in the Property section, click on Referral Exclusion List
  1. Add each domain to the list separately

Google Analytics Tips For Better Reporting With Cross-Domain Tracking

The following tips aren’t required for cross-domain tracking implementation, however, utilizing one or some of them will make your reporting life easier!

Add a hostname filter to see full URLs in your reports

By default, Google Analytics reports on pages using the page path, leaving the hostname out. When you have traffic from two different domains going into one Google Analytics property, this can make it tough to determine which page belongs to which site in your reports. For example, the homepage on both sites may report as “/” in Google Analytics. 

While you can always add the hostname as a secondary dimension in these reports, this step can be eliminated altogether by setting up a hostname filter in your Google Analytics view. With this, your page reporting will report the full page URL - including hostname. 

I always recommend leaving one Google Analytics view unfiltered, so you may want to set up a new view for your hostname reporting.

Here are the steps to setting up the hostname filter:

  1. Open up the Google Analytics view that you’ll be using for cross-domain reporting
  2. Go To Admin in the left-hand menu
  3. Go to Filters under the View section

Create a filter with the following setup:

You should now see your pages populate with the full URL in your Google Analytics reports - including the Realtime reports if you want to check it right away!

Set up a separate view for each domain to view traffic separately

While it’s great to have data from both domains going into one place, sometimes you’ll want to view the data for each domain separately. For this, separate views can be created to filter traffic for each domain. Here’s how to set this up:

  1. Go To Admin in the left-hand menu
  2. Click +Create View

Now we’ll want to filter this view so it only includes a single domain’s traffic. 

Note: Traffic will only start building in filtered views from the day you create them - they are not retroactive, so the sooner you set them up, the better.

  1. Go to Filters under the same menu, and click +Add Filter
  1. Create a filter that looks like this 
  1. Repeat steps 1-4 for each domain

How To Test If Cross-Domain Tracking Is Working

Simo Ahava offers the best solution that I’ve found for testing cross-domain tracking to make sure it’s working (not surprising!). In his article Troubleshooting Cross-Domain Tracking In Google Analytics, he recommends browsing the first domain with custom UTM parameters and then clicking a link to the second domain. 

Simply create a segment in Google Analytics containing your custom parameters and voila! You should see yourself as a single user and session and see pageviews from both domains (if you don’t have this voila moment, Simo’s article is a great place to start troubleshooting). 

And there you have it! You now know how to set up cross-domain tracking using Google Tag Manager and how to check your work to ensure accurate tracking. 

Have you run into a particularly tricky tracking or reporting issue that you need help troubleshooting? I’d love to hear from you! Check out our Data & Analytics center and contact us if you want to talk all things tracking & reporting.

Categories: Data Analysis
POST
Author's Headshot
By Sarah Burke
Share

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *