Search
Close this search box.

How to Set Up GA4 Cross-Domain Tracking

Last Modified on July 8, 2024

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:

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.

How to set up cross-domain tracking in Google Analytics 4 summarized steps:

  1. Go to the GA4 Admin section.
  2. Select Data Streams under the Property settings.
  3. In the Web tab, select your website’s data stream.
  4. Click Configure tag settings.
  5. Select Configure your domains.
  6. Add the domains for cross-domain tracking by clicking on the Add condition.
  7. Select Contains for the Match Type.
  8. Add your domain in the Domains box.
  9. Repeat steps 6-8 to include your additional domains.
  10. Click Save once done.

Let’s dive into each step of the process

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. 

Accessing the admin section in ga4

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.

Selecting a ga4 web data stream under the property column

4. Scroll to the bottom of the page and click on Configure tag settings.

Configuring tag settings in GA4

5. Select Configure your domains in order to specify a list of domains for cross-domain measurement. 

Configuring your domains in GA4

6. Here, you will add the domains you want for cross-domain tracking. To do this, click Add condition.  

Adding conditions for cross-domain tracking in GA4

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.

Include the main domain using the contains match type in the configuration section

9. Repeat the process starting from Add condition to include your second domain and click Save

Example of two domains configured for ga4 cross-domain tracking

🚨 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. 

Main domain button click sending to second domain

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. 

Example of the gl parameter confirming successful cross-domain tracking

For another way to test your configuration, install and enable the Google Analytics Debugger chrome extension and navigate to the DebugView report in GA4.

Accessing the debugview report in ga4

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. 

Selecting the pageview event in the debugview report

Select it and details related to the event will appear. Under Parameters, take note of the following:

  • ga_session_id
  • page_location

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.

Identifying the ga session id in the debugview report

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. 

Example of the configure your domains section for subdomain tracking

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

Finding the pageview and ga session id in the debugview report

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. 

Recognizing identical ga session id for a domain and its subdomain

FAQ

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:
URL redirects 
Conflicting scripts

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. 

When it comes to conflicts with other scripts, a javascript method such as the Event.stopPropagation() could prevent your event from bubbling up the DOM. 

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. 

Summary

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!

MeasureMasters

REOPENED!

Master Data & Analytics with MeasureMasters

Exclusive Courses & Workshops | Ongoing Troubleshooting | Support Resources, Tools & much more

Related Posts

Subscribe
Notify of
guest
10 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Itai
Itai
1 year ago

Is there a limit on how many domains can be added to the configuration?

Thibault
Thibault
1 year ago

Hi Julian,

Thanks for this blog post.
I’ve followed all the guidelines that you provide :
– I configure the two domains in the configuration tab inside GA4;
– When I go from domain A to domain B, the “_gl” parameter appears on the URL of the domain B

However, when using the debugview in GA4, the “ga_session_id” change when I land on domain B and a new session begin.

What is wrong with my configuration ? I’d appreciate a lot your help.
Thanks in advance

yassine
yassine
1 year ago
Reply to  Thibault

i have the same issue

francesco
francesco
1 year ago

Thk for this great tutorial, I setup GA4 like you teach in your site but I see an unexpected increase of direct session compare ga4 and univ, here you can see the traffic comparison https://drive.google.com/file/d/1NZVB5LlUl-rJgwvqrcLSzY0xKGTMGeDd/view?usp=share_link , is it a ga4 bug? did i made a mister on the setup?

Eric Huguenin
Eric Huguenin
1 year ago
Reply to  francesco

Hi,thanks for the comment. This is a great question. Just to preface, it’s always tricky to grasp the underlying problems without access to an analytics account. That being said, it is usually expected that GA4 shows a lower number of sessions. UA and GA4 don’t count sessions the same way, and typically GA4 will have sessions that last longer than UA as they don’t time out after midnight. As you probably noticed, GA4 takes time to send events and this delay is also a factor. GA4 also makes a statistical estimation of your sessions (supposed to provide more accurate numbers),… Read more »

Nicky
Nicky
1 year ago

Do we also need to set each domain up as its own data stream?

Sofiia Wycisk
Sofiia Wycisk
1 year ago
Reply to  Nicky

Hi Nicky, no, it is not recommended to create multiple web streams within 1 property. You should utilize filters, comparisons & segments instead to segment your data.

Mark
Mark
11 months ago
Reply to  Sofiia Wycisk

Do you know of any good guide that might explain how to do this? I can’t seem to segment the data properly between the 3 domains I’ve set for cross domain tracking.. Thanks!

delphin
delphin
1 year ago

What is to do if I actually want to exclude the subdomain from being tracked. For instance if the sub domain is for development/staging.
Therefore I want to track “www.example.com” but not “staging.example.com” because only the first one is the production website.

yassine
yassine
1 year ago
Reply to  delphin

i have the same question

now it's time to

Start measuring like a master

Itching to jump into the world of MeasureMasters? This is what you have to look forward to.

Ready to take your digital marketing to the next level?

Subscribe to our newsletter and stay ahead with our latest tips and strategies.