In this post, we're going to delve deep into a topic that keeps analytics consultants in business – Cross-domain tracking.
Cross-domain tracking is a term we use to describe the act of tracking multiple domains in a single Google Analytics property.
Now, cross-domain tracking is a pretty advanced concept that is not easily understood. It's also not necessary for everyone who operates a website. The truth is that most Google Analytics users are tracking just one domain name at a time.
But for those who want to track multiple domains in a single property? It takes a lot of problem solving and debugging to make this tracking solution work effectively.
There is no simple cross-domain tracking solution
Now before you get too far into this article, I want to warn you that there's no way I can promise to “quickly solve your cross-domain tracking issues.”
This is a 2,000+ word article that explores cross-domain tracking from several angles. Chances are, the information within will help you solve your cross-domain tracking problems. But it's going to take some work on your end.
With that out of the way, I'm going to do my best to explain this advanced concept in Google Analytics. Not only that, but I'll give you a set of steps that you can follow to help solve any cross-domain tracking issues that you are experiencing.
In the post and video below, we'll take a look at when you need to use cross-domain tracking.
We'll show you how to use Google Tag Manager to help you set up cross-domain tracking. And I'll outline some steps that can make installing this tracking solution easier.
- Standard GA tracking
- Cross domain tracking scenarios
- Client ID and cross domain tracking
- GTM and cross domain tracking
For those of you who were about hit the back button because you heard advanced and Google Analytics.
We've included both an Austin Powers and a Spice Girls meme in this post.
That's right; we're making history on Jeffalytics. We are going to become the first web analytics article to include a reference to the Spice Girls*! If that doesn't make this post worth reading in of itself, I'm not sure what does?
* Note: I have no idea if others have mentioned the Spice Girls before in a web analytics article.
Interested in Google Analytics? Get our Google Analytics Account Setup & Optimization Checklist
Why would you need to use cross-domain tracking?
To unravel the mystery that is cross-domain tracking, we need to start with how standard web tracking works.
Standard Google Analytics tracking
Most websites, businesses, and blogs only need to track one domain at a time. The default Google Analytics tracking is setup to treat each domain as a property.
So, using standard Google Analytics tracking:
One domain = 1 Google Analytics property.
User behavior that occurs on a domain is tracked in Google Analytics using sessions. When a user leaves a domain, their session ends.
Cross-domain tracking scenarios
But what if you need to track user behavior across more than one domain?
Let's think about this regarding e-commerce. We can use the Google Merchandise Store (GMS) analytics account as an example.
As you can see from the example below, the GMS is getting a lot of referral traffic from sites that Google owns.
The GMS's highest converting traffic is coming from gdeals.googleplex.com.
Here's the potential problem. If these sites are primarily referring to themselves (i.e., self-referrals), they can give you an inaccurate picture in your analytics reports.
It might be better to track the referring domains in the same analytics property as the Merchandise store. This way, the original traffic source would get credit for the sale, not the referral between Google properties.
To put it more simply, if we link these domains in Googe Analytics, a user session that starts with a search visit landing on gdeals.googleplex.com will continue as the visitor lands on the Google Merchandise Store. So, shopping behavior beginning with one domain will carry over to the next domain in Google Analytics.
Makes sense, right?
Cross-domain tracking for third party shopping carts
Here's a typical scenario where cross-domain tracking makes sense: E-commerce platforms with third-party shopping carts.
In this situation, users land on the main site to view a product. When the user goes to check out, they head to a shopping cart on a different domain.
Without cross-domain tracking, the shopping behavior and check out won't get linked together. The default Google Analytics settings will not track conversions across domains. So, these merchants need to connect their domains in Google Analytics. Otherwise, the conversion will credit to the third party shopping cart, not the original traffic source.
Tell Google Analytics what you want
Google Analytics is smart. Very smart! But Google Analytics can't read your mind.
If you decide you need to track more than one website with the same property?
Then you are going to have to throw Google a friggin' bone!
Cross-domain tracking is not an automated strategy. There's no easy button for this one.
You are going to have map things out so you can tell Google Analytics what you want it to do.
What you really, really want.
Ok, now that we have both of our dated memes out of the way, as promised, let's look at how to set up cross domain tracking.
Before we can get started in Google Tag Manager (GTM), we need to understand clients IDs.
Client ID and cross-domain tracking
Let's use the Merchandise Store demo account to look at how client IDs work.
The store is getting referral traffic from YouTube.
If we look at where this traffic is coming from, we can see that it comes from the footer on the YouTube about page.
I'll preface the rest of this example by saying that this traffic is accounted for correctly in the Merchandise Store analytics account. Since these are two entirely different websites, it wouldn't make much sense to link them using cross domain tracking. The Youtube traffic should track as referral traffic.
But, there could be a use case where the person managing the Merchandise Store wants to link these domains in their analytics reports.
To investigate this scenario further, we need to see what's going on in Google Analytics on each of these sites.
Using the Google Analytics Debugger to check our client ID
We can use the Google Analytics Debugger Chrome extension to view our client ID for the GMS store. When I activate the debugger, I can see that the GMS tracking is sending a lot of hits to their analytics account.
Looking through the data on the debugger, I can find my client ID. This ID will track me through my entire user experience on the GMS website.
If I look at the debugger data on YouTube, I see that I have a different client ID than I did on the Merchandise Store page. Two unique domains, two unique client IDs.
If we wanted to merge these sites in Google Analytics, we would need to modify the tracking code. We would have to tell Google to assign the same client IDs across both domains.
Let's look at how we would use Google Tag Manager to modify our code.
Using Google Tag Manager to setup cross-domain tracking
For this example, I'll use my own Google Analytics account (I don't have access to the code for the GMS account).
To start modifying my cross-domain tracking setup, I need to create a new variable in Google Tag Manager (GTM).
I'll start by choosing the Google Analytics settings variable.
Once I am in this variable, you can see that I have an “auto” cookie domain.
The “auto” cookie domain is the standard cookie tracking for all analytics accounts. But for cross-domain tracking, we need to adjust our cookie domain setting.
We need to set our cookie domain to match the main site we are tracking. So, for our example, I would set my cookie domain to www.jeffalytics.com. And I would also set the cookie domains for the domains I am adding to this property as www.jeffalytics.com.
I also need to match my tracking IDs on my other domains to Jeffalytics.com.
Adjusting these settings will synchronize client IDs across my domains. Syncing the client ID is how we make sure our users' sessions continue across our linked domains.
Let's look at this example using my main site, and two fictional store domains:
jeffalytics.com. jeffalyticsstore.com, and store.jeffalytics.com
To set-up cross-domain tracking, I should change my cookie domain to www.jeffalytics.com (or just jeffalytics.com). I need to enter my web property ID, and I need to auto-link these domains.
Auto linking domains
To auto link my domains, I select more settings in Google Tag manager. Then, I navigate to the Cross Domain Tracking drop down.
In the auto-linking field, I enter each of my domains in a comma separated string.
After I double check my settings, I can save my progress to enable my changes.
Referral exclusion list
The final step of this setup is to add my domains to my referral exclusion list. To add referral exclusions, you need to go into your master view for your primary property. From the tracking info menu, select the referral exclusion list. Then, add your linked domains as referral exclusions.
Once your cross-domain tracking installation is complete, it's important to check your work and debug any problems.
You need to make sure your cookie domains are tracking correctly. You also want double check that your client IDs match across your linked domains.
Cross-domain tracking can also be setup using customizations to your base Google Analytics code (if you're not using Google Tag Manager). However, this is a process that involves a lot of debugging, and I'm not sure how to do this with gtag.js. And the bigger the site, the more difficult it becomes to customize the installation.
The steps we just worked through are the basics steps for a cross-domain tracking installation. There are potentially some other areas where you might need to link your domains. For example, if you are sending traffic between domains through forms, then you would need to do more customization to link your data.
Do you want to see a live cross-domain tracking installation demo?
Would you like help to troubleshoot your cross-domain tracking setup? For one lucky reader, we would be happy to help setup your tracking and do a live demo for the Jeffalytics YouTube channel.
Leave a comment below if you want us to look at your cross-domain tracking problem. If your problem is ideal for a live demo, I'll walk you through how to share access to your account in advance of the video. Then we'll do a demo of your cross-domain tracking setup.
The final video would be edited so that we don't compromise any of the privacy details for your account.
Essentially, you'll get high-level Google Analytics consulting for free!
Let's recap the steps that will help us get better at cross-domain tracking.
1) Map out what you want to track on paper
Before you start messing with your tracking code, map out what you want to do on paper. Mapping out your tracking plan will add clarity to the solution you're trying to implement.
2) Tell Google Analytics what you want to track
The Google Analytics default settings are one-size fits all tool. If you need a specialized solution, you have to tell Google what you want to track.
3) Make sure your cookie domain is set consistently. (Don't trust auto)
If you're trying to track more than just your main domain in a single property, don't trust the auto setting. Make sure to set your cookie domain consistently across the domains you need to track.
4) Use GTM to set cookie domains and auto linking domains
GTM offers the easiest solution for implementing cross-domain tracking, so if you haven't already made the switch… here's reason #6,102 to switch over to Google Tag Manager.
5) Add referral exclusions
Think of adding referral exclusions as an extra line of defense. It might not solve the problem, but it's a best practice to put them in place. Just do it! Exclude the domains your linking to in your main property from being treated like referrals.
Cross-domain tracking is not easy!
Cross-domain tracking sounds complicated because it is. Once you get into the nuts and bolts of linking domains, there are a lot of steps that need to happen in a proper installation.
The key to a successful installation is defining the steps you need to take. And then updating those steps as you work through the setup process.
What should you do if you have problems with cross-domain tracking?
Do you need help with cross-domain tracking? If you're willing to participate in a cross-domain tracking case study, then leave us a comment. We'll take a look at your account, and see if we can fix your problem.
What do you think? Would a live cross-domain tracking demo make for compelling entertainment? Will it save us from using Austin Powers and Spice Girls memes to liven-up analytics?
Tell us what you really, really want! (but do it in the comment section below).
Interested in Google Analytics? Get our Google Analytics Account Setup & Optimization Checklist
This post and video was episode 24 in our 90-Day Challenge digital marketing series.
The easiest way to join the 90-day challenge is to subscribe to our YouTube channel. YouTube will send our subscribers weekly emails about all the videos we published over the past week.
Want to know about each video as soon as it comes out? Sign up for the 90-day challenge email newsletter. The newsletter will be the best way to make sure you don't miss any of the content.