If you own multiple websites and are interested to understand how your users behave differently on each of them, GA4 provides a solution known as cross-domain tracking.
GA4 cross-domain tracking is actually pretty easy to set up with Google Tag Manager.
However, there are some considerations and possible hiccups to keep in mind during the process, and we are here to help you with that!
Here’s an outline of what we’ll learn:
- What Is Cross-Domain Tracking?
- How Do I Set Up Cross-Domain Tracking in Google Analytics 4?
- How Do I Know if Cross Domain Tracking Is Enabled?
- How Do I Set Up Cross-Domain Tracking for Subdomains?
Let’s get started!
What Is Cross-Domain Tracking?
Cross-domain tracking allows recognition of the same users as they navigate between different websites.
Technically speaking, Google Analytics identifies users and their sessions by assigning each of them an identifier.
The identifier for a user is the client ID while that for the session is the session ID.
It’s important to note here that GA4 doesn’t physically track users. Instead, every user is identified through the browsers or devices being used to access websites.
As you navigate across domains, these identifiers are stored in cookies and their values are added to all the links (outbound links) that lead you to another site. This is achieved via a URL parameter.
Why Is Cross Domain Tracking Important?
This process is very important for two reasons.
First, it allows you to understand user journeys as they navigate across different domains. Second, it ensures that the data in your reports are more accurate.
Let’s look at a common example.
Let’s say that you’re running a marketing campaign that sends users to learn about your product/service on website A. The visitors who are interested are then directed to website B to complete a conversion which could be a purchase or signup.
If you don’t have cross-domain tracking set up:
- You won’t be able to know which of your marketing campaigns are responsible for generating sales or conversions
- Your GA4 reports will be inflated. They will show more users and sessions than the actual number. This happens because each visit from the first website to the second one will be counted as a new user with a new session
Now that we understand the importance of cross-domain tracking, let’s jump right into how to implement it!
How Do I Set Up Cross-Domain Tracking in Google Analytics 4?
🚨 Note: Make sure that you have installed the same GA4 Property on all the sites you want to track.
This means that you must have the same measurement ID installed on each domain.
Having a measurement ID implies that you’ve already installed Google Analytics. If you don’t know how to create an account or install GA4 with Google Tag Manager, check out this resource where we explain how to upgrade to Google Analytics 4.
1. The first step is to go to the admin section of your account. You can access it by going to the bottom left corner of your account page and right-clicking on Admin.
2. Under the Property column, you will find a list of options. Select Data Streams.
This will open a section on the right side of your screen that will show all the data streams linked to your account. These are your websites and applications.
In the following example, there is only one data stream that we’ll use for demonstration purposes. Yours may look like https://mywebsite.com/.
3. Since we’re dealing with websites in this example, right-click Web and select your stream.
4. Scroll to the bottom of the page and click on Configure tag settings.
5. Select Configure your domains in order to specify a list of domains for cross-domain measurement.
6. Here, you will add the domains you want for cross-domain tracking. To do this, click Add condition.
7. In Match type, select Contains.
8. In the Domains box, you can add your domain.
The domain in this example is pantheonsite.io, so if yours is www.mywebsiteA.com, then put in mywebsiteA.com.
9. Repeat the process starting from Add condition to include your second domain and click Save.
🚨 Note: If you have cross-domain tracking in Universal Analytics, you need to verify that the same domains are being tracked in GA4.
To know more about the configuration for Universal Analytics, you can read this post on how to set up cross-domain tracking in Google Analytics.
How Do I Know if Cross Domain Tracking Is Enabled?
There are several ways to check cross-domain tracking in google analytics, and we’ll look at some that you can use for validation.
First, wait for around 5 minutes for your changes to be processed. Then, head over to your first website (www.websiteA.com) and click any outbound link sending you to the second site (www.websiteB.com).
Our example is of a website that promotes offers for products from the online store (both are demos).
Since you’re on your way to becoming an analytics ninja, let’s take advantage of the limited hoodie offer. Clicking on the Shop Now button will send us to the online store. There, we can redeem the coupon and buy the hoodie.
After being sent to the second domain, have a look at the URL. You’ll notice that it is pretty long. Look specifically for the _gl parameter.
If it’s present, congratulations! The cross-domain tracking has been enabled for you.
Go back to your first website and refresh the page. In the DebugView report, you will see a page_view event that would have occurred around the same time you visited your page.
Select it and details related to the event will appear. Under Parameters, take note of the following:
In this example, the ga_session_id is 1659237. Note that this ID is unique, so yours will be different. Moreover, it must remain the same when you click a link that sends you to the other domain.
Back to your first domain! Click on any outbound link pointing to the second domain and repeat the process we just completed in the DebugView report.
The ga_session_id should be the same as the first one. However, the page_location parameter should be for the second domain.
At this point you can be sure that users and their sessions persist as they navigate across domains.
How do I Set Up Cross-Domain Tracking for Subdomains?
GA4 tracks subdomains automatically. As a result, you don’t have to go through the same process we’ve covered above.
To give you an idea of how this works in real life, let’s see how subdomain tracking shows up in GA4.
Subdomains help you create separate parts (that also include separate linked sites) of your website. This is often the case with blogs, online stores, or localized content that need to be organized differently while remaining connected to the one main site.
For example, let’s say that you own a website called www.mywebsiteA.com.
If you serve different cities with varying offers, your subdomains may look like www.newyork.mywebsiteA.com or www.paris.mywebsiteA.com
Here, the website www.measure.school and our subdomain www.demoshop.measure.school will be used.
🚨 Note: Remember that you don’t have anything to configure for subdomain tracking. You should not add your subdomain or domain in the section Configure your domains.
This area should be blank unless you’re doing cross-domain tracking for a completely different domain (then it’ll look like our previous setup).
Let’s visit our domain www.measure.school to generate a pageview event. Then, we’ll go to the DebugView report. Once there, pay attention to the session_id.
In our main domain www.measureschool.com, let’s click on a link sending us to our subdomain www.demoshop.measure.school which is our demo shop. This will generate a new pageview event in the DebugView.
Go back to the Debugview, select the new page_view event, and under Parameters, look at the ga_session_id once again. The ID number should be the same.
This proves that implementing cross-domain tracking for subdomains is not needed as GA4 does the job for you.
Do Subdomains Need Cross-Domain Tracking?
No! If you have the same GA4 Measurement ID on all the subdomains, you don’t need cross-domain tracking.
Cookies are created by default in your main domain and also remain in your subdomains.
What is cross-domain tracking in Google Analytics 4?
Cross-domain tracking is a way to identify users who navigate across different domains without treating them as separate users.
Google Analytics identifies users by assigning each a unique client ID and session ID. Both of them remain consistent as the users visit another website where cross-domain tracking is implemented.
Without this linking feature, a visitor going from one site to another will be considered two different people (specifically two different browsers or devices).
Conceptually, cross-domain tracking in Google Analytics 4 is not different from its previous version. The only difference is that GA4 makes it easier to set it up in just a few clicks.
Do I Need to Configure the Referral Exclusion List for Cross-Domain Tracking in Google Analytics 4?
This is not needed. Once you’ve configured your domains, GA4 will take care of this automatically.
However, you should add to the referral exclusion list any third-party domains that are involved in the transaction process or managing key interactions.
These are usually payment gateways like PayPal or email marketing platforms that send password recovery steps to your email list.
There are odd cases where your domain may appear in the referral report. In this case, you should include it in the referral exclusion list.
Moreover, you can create a source/medium report in GA4 to examine which channels are passed as referral traffic.
I Followed Everything but Cross-Domain Tracking Still Doesn’t Work. What Can I Do?
If, for some reason, you don’t see the _gl parameter in the URL of the destination domain, verify that the domain matches the one in the Configure your domains section.
If this doesn’t work, the issue most probably originates from prior configurations in the destination domain.
This is due to two reasons:
In both cases, you’ll need the help of a developer.
In some instances, your destination domain could have a redirect or quickly remove the _gl parameter that was added to the URL. You can resolve this issue by asking your developer to ensure that the parameter _gl doesn’t get dropped.
Simply put, when a user clicks on your link, this information and any related one will travel through a series of HTML elements to reach an event listener that waits to register it.
The problem occurs when some scripts prevent this information from reaching the listener.
Great job! You have made it to the end!
GA4 features can seem as clear as mud for many people. However, this isn’t the case for cross-domain tracking. Compared to its predecessor GA3, this feature is much easier to configure.
That being said, there are a few caveats to be aware of which can distort the real story behind your data. I encouraged you to audit GA4 implementations for your organization, and you can speed up this process with our 16 questions to ensure your account is set up correctly.
Have you successfully implemented cross-domain tracking? Let us know in the comments below!