Monday, April 15

Cross-domain tracking in Google Analytics 4

Note: If you are looking for a Cross-domain tracking guide for Universal Analytics, read this guide instead.

If you are familiar with cross-domain tracking in UA, you probably know that most of the configuration is done either on the code level (e.g. in gtag.js) or in GTM (GA tags). Because of that, many marketers and web analysts were confused about what to do where. Luckily, in Google Analytics 4, things have been greatly simplified.

In this guide, I will show how to configure cross-domain tracking in Google Analytics 4. First, we’ll start with the problem that cross-domain tracking solves and then we will go to the actual configuration.

Table of contents

Don’t need the introduction? Jump to the configuration

If you are already experienced with cross-domain tracking and you don’t need any introductions, then jump to this section where I’ll show how to configure it in Google Analytics 4.

But if you are new to this, continue reading.

The problem of multiple domains

This will be very simplified.

By default, Google Analytics tracks users with first-party cookies. You land on a website and GA (on behalf of your website) stores a _ga cookie (actually, it stores more but let’s focus on _ga) in the visitor’s browser (with some random identifier). When you, as a visitor, navigate from page A to page B (of your website), Google Analytics checks the values of that cookie.

Since the cookie is still present (and its value is the same), GA understands that you are the same person who just was on page A, therefore, the 2nd page view is also included in the same session and user.

And that’s great! With web analytics tools (not just GA), you can track how visitors are using your website, what are they doing, etc. Of course, cookies, as a technology, are far from being perfect and have a lot of drawbacks but let’s keep this topic for another blog post.

So where is the problem?

First-party cookies (created on behalf of your website) cannot be shared between two separate domains (due to cross-domain policy). So if you have a website where the journey of a visitor starts on and eventually, ends on the, Google Analytics on the will not able to understand that this is the same visitor as on the (even if the GA property on both domains is the same).

When the visitor navigates from domain A to domain B, Google Analytics on domain B cannot reach particular cookies of domain A, therefore, it creates new ones.

The result? Google Analytics (and other cookie-based web analytics tracking tools) will see you as two separate visitors, one on the and one on the

And that’s a big problem. You will see too many users in your GA reports. Every person who visits both and will turn into two users.

Also, if a new user is tracked, then naturally, a new session will also start and in your traffic acquisition reports, you will your This situation is called “self-referral”.

What should you do? Enter cross-domain tracking.

What is cross-domain tracking in Google Analytics 4?

It is a workaround that allows webmasters/marketers/analysts to send user’s/visitor’s identifiers from domain A to domain B and preserve the session information. That way, the visitor is being tracked as the same person across multiple websites/domains.

In order for this to work, both websites must use the same GA4 property.

How does cross-domain tracking work in Google Analytics 4?

Here’s the process in a nutshell.

When a visitor navigates from to, Google Analytics 4 will pass a special parameter to’s URL. Thanks to that parameter, the GA on will be able to update Google Analytics 4 and will understand that it’s actually just one person navigating between two websites.

Will Google Analytics track subdomains?

Yes, and you DON’T need cross-domain tracking for that.

If you want to track different websites that belong to the same domain (e.g. and, Google Analytics 4 will handle that automatically.

So if you google something like “is subdomain considered as cross domain?”, the answer in this context is NO.

How to configure cross-domain tracking in Google Analytics 4?

Alright, now that we got familiar with the problem (and the solution), it’s time to configure it.

Before you do this, remember one requirement: both websites (that you are going to include in cross-domain tracking) must use the SAME GA4 property installed. The code can be installed directly on the site (gtag) or via GTM. But it’s important that this happens in the same property.

Step #1. Go to the Admin of Google Analytics > Data Streams and select web data stream

Step #2. Go to More Tagging Settings.

Step #3. Click Configure your domains

Step #4. Enter all domains that should be included in the cross-domain tracking setup. Then hit save.

That’s it. You DON’t need to configure the referral exclusion list for this. GA will handle that automatically.

Important: if you also run Universal Analytics on a site, you need to keep in mind something. _ga cookie is shared by both GA versions. Thus your cross-domain setup in Google Analytics 4 admin should match the settings of Universal Analytics. In other words, the domains in both configurations must match.

Note: this will also affect your automatic outbound click tracking in Enhanced Measurement. Domains that you enter here will not be treated as outbound clicks anymore.

Test the setup

Once you have saved your changes, wait for a minute or so and then go to your first website (let’s say it’s On that website, you will have to find a link that will redirect the visitor to

Click it. Once you are redirected to the 2nd domain, check the URL. It should contain the _gl= parameter with a lot of stuff.

Then you can also enable the GA Debugger extension and go to the DebugView of Google Analytics 4. There you should find your device and once you do that, you should see that you have at least several page_view events. In some events, page_location parameter will contain the And in other events, it will contain the

That is the final result you should be looking for.

Keep the redirects in mind

If the URL on does not contain _gl parameter, there might be a JavaScript redirect somewhere along the way. Try using the extension Redirect Path to identify problems.

Install the plugin, then go to and click the link to Then click on the Redirect Path extension and see if the _gl parameter was there. If it was at first, but then was lost, you should talk to your developers and ask them to debug this further. The goal here is to persist that _gl parameter.

Frequently asked questions

Some of these questions were already covered in this blog post but I will still list them here (because not everyone carefully reads every paragraph). So here’s the TL;DR version.

What is cross-domain tracking in Google Analytics 4?

It is a workaround that allows webmasters/marketers/analysts to send user’s/visitor’s identifiers from domain A to domain B and preserve the session information. That way, the visitor is being tracked as the same person across multiple websites/domains.

Why is cross domain tracking important?

Without it, the number of your visitors would increase and be less accurate. Also the number of sessions will increase because when the visitor navigates to the second domain, a new session will be started (because GA treats this as a different user).

Do I need cross-domain tracking for subdomains?

No, if you are talking about the subdomains of the same domain. Google Analytics 4 (and previous versions) is capable of tracking visitors across subdomains. So, you don’t need to do any additional configuration.

Do I need to configure the referral exclusion list for cross-domain tracking in Google Analytics 4?

No, Google Analytics 4 handles self-referrals automatically based on the domains that you entered in the “Configure your domains” section (source). A referral exclusion list is needed for things like payment gateway domains, etc.

How do I test cross domain tracking?

You can verify your cross domain setup by clicking the link on the first website (that redirects you to the second website). The URL of the second website should contain the _gl= parameter. Also, you can check if the _ga cookie is the same.

Take a look at the screenshot below and perform this check on both domains. The _ga cookie’s value must be the same on both domains. Also, keep an eye on the “Domain” column of the cookie list.

Google Analytics 4 Cross Domain Tracking: Final words

Cross domain tracking in GA4 requires less configuration compared to Universal Analytics and the process is more straightforward. No more allowLinker or Auto Link Domains.

Just go to the admin of your GA4 property > Data streams and configure your domains in the Web Stream.

With the rise of Google Analytics 4, you can clearly see the direction that Google is taking: less of configuration in the code or GTM, more in the GA4 interface itself. But that does not mean, that GTM becomes useless. There are still many things where Google Tag Manager is absolutely necessary.

Source: analyticsmania

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x