Last Modified on March 25, 2024
🚨 Note: We’ve created a guide on this same topic but for GA4 instead of Universal Analytics. If you’re interested in the GA4 version instead, check out this article.
If you have two web domains that you want to track in a single Google Analytics property, you’ll need the help of something called cross-domain tracking.
Sign up to the FREE GTM for Beginners Course...
It will combine user data across multiple connected websites into a single session in Google Analytics.
Here’s an overview of what we’ll cover in this guide:
- What is cross-domain tracking?
- When to install cross-domain tracking
- How to set up cross-domain tracking
- Setup for multiple Google Analytics properties installed in GTM
- Testing your cross-domain tracking implementation
What is Cross-Domain Tracking?
Cross-domain tracking (also called cross-domain measurement or site linking) is a technique that combines user journeys across related websites into a single session in Google Analytics.
With the default setup, Google Analytics can track individual users on your website as long as they don’t leave. You can observe patterns when your site visitors navigate between pages, engage with content, and generate conversions.
But sometimes your business funnel spread across multiple domains. For example, maybe your eCommerce site’s shopping cart is hosted by another website. Or maybe you have subsites on a bigger multisite.
Cross-domain tracking is where it comes in.
By linking your related sites (like your eCommerce store to your shopping cart). You track users who navigate between those sites when engaging with your business.
This gives you a complete picture of the user journey across every step.
Here’s a quick demonstration. An eCommerce shop with Google Analytics installed via Google Tag Manager.
When Google Tag Manager detects a pageview for this website, we see a new page view in the real-time reports in our Google Analytics dashboard.
However, this eCommerce site is also connected to a blog site via cross-domain measurement.
And if a user navigates to this connected website, GTM will send any Tags that fire to the same Google Analytics property as part of the same user session.
Without it, Google Analytics incorrectly counts this interaction as two different users that entered the two different websites.
This data can be misleading. Since there’s only one user navigating between two linked sites. This results in inflated metrics.
It solves this problem by identifying the two sessions. And combining them into a single user session.
This more accurately reflects the number of website visitors you have. And also better represents their user journey.
When to Install Cross-Domain Tracking
Here is a little flowchart to help you decide whether you need to install it or not.
The first consideration is whether or not you have multiple domains.
This refers to anything that occurs before .com/.net/.org/etc., but does not include subdomains.
Using our example from earlier, demoshop.com and demoblog.com would be two separate domains.
These two sites would most likely need to be linked with cross-domain tracking in order to track user sessions between them.
But, measureschool.com and store.measureschool.com are part of the same domain. The store site is considered a subdomain of the main site.
You don’t need to install to track user sessions between the two sites.
The second major consideration is whether or not you use the same Google Analytics property to track users on two separate domains.
If you already have two separate Google Analytics properties to track the two separate domains. You don’t need to install cross-domain tracking.
You’ll see the correct number of users in each property, and cross-traffic won’t inflate your metrics.
But if you want to track the two separate domains with one property, then I recommend installing cross-domain tracking. It will keep your data reliable and consistent.
Even users navigate back and forth between your two sites. It is very important because we want to attribute the conversion data to the correct original source.
How to Set Up Cross-Domain Tracking for a Single Tag
If you decided that you need cross-domain tracking, you need to link your two domains in Google Tag Manager. (If you don’t have Google Tag Manager on your website, check out our handy Google Tag Manager installation guide!)
The following method is simple and works well. You only need to install it on one Tag. If you have several Tags that you like to include in your cross-domain tracking, then skip ahead to the next section.
On the page, we have the same Tag Manager account as on our demo blog.com. Which is quite convenient because we can control both tracking codes in one Google Tag Manager account.
You can’t do this if you have two Google Tag Manager accounts
Right now we have just one Google Tag Manager account. We have our Google Analytics pageview Tag that sends the data over.
In this Tag, we need to install something to enable cross-domain tracking. And these are two settings. How can you install these settings?
You need to check on Enable overriding settings in this tag. Then click on More Settings.
Under the dropdown Cross-Domain Tracking, you’ll find the field Auto Link Domains. Enter the domains that you want to link (separated by a comma and space).
This will tell Google Analytics to link user sessions across the two sites.
Next, open the Fields to Set dropdown. You’ll need to add a field named allowLinker and set the value to true.
If you just need to install cross-domain tracking for one Tag, then this should be enough to start your tracking.
However, if you want to use cross-domain tracking for multiple Tags, then this next step will make the process much easier.
Cross-Domain Tracking with Multiple Google Analytics Tags
If you have multiple Google Analytics tags installed on your Google Tag Manager account, you might want to install cross-domain tracking directly into your Google Analytics settings variable.
The benefit is you don’t need to edit each individual Tag in order to start using cross-domain tracking.
For example, if you were using the previous method, you would need to individually install cross-domain tracking across every single Tag for different events, transactions, or any other user actions.
But if you have a common Google Analytics settings variable across all of your Tags, then you can install cross-domain tracking once.
This will apply to all your Google Analytics Tags.
Go to Variables in your GTM dashboard. Select your Google Analytics settings variable under User-Defined Variables.
In the variable configuration panel, click on the More Settings dropdown.
Scroll down until you find the section called Cross Domain Tracking. This process will look very similar to the installation process for a single Tag.
We’ll be editing our variable configuration instead of our Tag configuration.
In the field, Auto Link Domains, enter the domains you want to use.
Next, go to the Fields to set dropdown. Under Field Name, select allowLinker and set the value to true. Save your configuration.
Cross-domain tracking will be installed automatically into all your Google Analytics Tags that use this variable.
Testing
To ensure that your new cross-domain tracking implementation is working, you should test it using the GTM preview mode.
To do this, click the Preview button near the top right corner of your GTM dashboard.
It is easy to identify when it is working correctly because Google Analytics accomplishes it by examining the user’s current web page for any links that go to the linked domain.
It attaches the user’s session information to any of these links.
When a user clicks on a link to the connected domain, session information is attached to the new web page. It is in the form of a query string in the URL.
This query string tells Google Analytics that the new pageview belongs to an existing session.
It will count you as one continuing user instead of a new visitor.
You can take your testing a little further by following a test user (yourself) around your site.
To do this, start by deleting any Google Analytics cookies on both sites. In the Chrome browser’s developer tools console, go to Application. Then select Cookies.
Select your connected websites (make sure to do this for both domains). Delete any cookies associated with Google Analytics.
On an open webpage on either of your linked websites, add the following query string to the end of the URL and hit enter: ?utm_source=test&utm_medium=test&utm_campaign=test
In your Google Analytics dashboard, go to the Real-Time report called Traffic Sources. You should see a new user with both the Medium and Source listed as a test.
Next, filter any following data in your real-time report by this “user”. It prevents your view from being clogged by any real users currently on your site.
To do this, click on the test (either the medium or source is fine).
This will filter your report so that you only see users with “test” as a medium or source.
Since this isn’t a label you’d expect to see from any real users, you know that any data in this real-time report should just be you using the preview mode.
With the filter in place, click the Overview report view to get a better picture of your impending test data.
If you navigate around your starting domain, you see a new pageview. It appears in your GTM preview console.
In your Google Analytics dashboard, you should see the corresponding data appear on your real-time report.
This all appears as one user (a single session). Even when navigating to new pages in the same domain.
Next, it’s time to test whether or not Google Analytics will retain the same session information. When you navigate to the linked website.
Click on a link from your current domain to your linked domain.
Google Analytics should recognize the query string. Include it on the Tag, and link the session data.
In your Google Analytics dashboard, the real-time report should continue to show just one active user. Even when the active page is part of a new domain.
If this is how your data behaves, then congratulations! You have successfully installed it on Google Analytics.
FAQ
When should I install cross-domain tracking?
You should install cross-domain tracking if you have multiple web domains that you want to track in a single Google Analytics property. It is particularly useful when your business funnel is spread across different domains or when you want to attribute conversion data accurately to the correct original source.
How do I set up cross-domain tracking?
To set up cross-domain tracking with Google Tag Manager, follow these steps:
1. Enable overriding settings in the Google Tag Manager Tag for your website.
2. In the “More Settings” dropdown, under Cross-Domain Tracking, enter the domains you want to link.
3. Add a field named “allowLinker” and set the value to true in the “Fields to Set” dropdown.
4. Save the configuration.
If you have multiple Google Analytics tags, you can also set up cross-domain tracking directly in the Google Analytics settings variable. This allows the tracking to apply to all your Google Analytics tags.
Can I set up cross-domain tracking for multiple Google Analytics properties installed in GTM?
No, cross-domain tracking is designed to track user sessions between multiple domains within a single Google Analytics property. If you have separate properties for each domain, cross-domain tracking is not necessary, as each property will track its own set of users.
Summary
If your online business uses multiple domains but just one Google Analytics property, then cross-domain tracking is a must-have.
It will help you keep your data honest. This allows you to build marketing campaigns and make business decisions with confidence. You’ll avoid inflated metrics, and you’ll have a clearer picture of users’ experiences engaging with your business.
Do you want to create versatile and precise tracking deployments? Check out our guide on how to use RegEx for Google Tag Manager.
What are some of your favorite use cases for cross-domain tracking? Have you run into problems keeping data consistent across multiple domains? Leave us a comment!
How about the conversion linker tag within GTM? Does it accomplish the same goal?