Does your website operate on more than one domain? For example, do you have an e-commerce site and a separate payment system domain? Or do your corporate website and blog site run on different domains? Then you need to examine the concept of cross domain in GA4 closely. Otherwise, your measurement may get complicated and you may not understand what you are measuring.

What is Cross Domain Tracking in GA4 and Why is it Important?

Cross-domain tracking is a Google Analytics 4 feature that allows you to seamlessly track users' journeys between different domains. This technology lets you track and analyze your visitors' interactions across multiple domains in a single session.

Cross-domain tracking is a Google Analytics 4 feature that allows you to seamlessly track the journey of users between different domains (for example, siteadi.com and siteadi2.com). GA4 requires a special configuration to track transitions between different domains while automatically tracking subdomains. In other words, you do not need to set up cross-domain for domains with the same hostname blog.siteadi.com and siteadi.com. To understand this better, I have created some visual scenarios below.

Today, many businesses provide services over different domains. For example, in the scenario shown in the diagram below, there are two different domains: zeo.org and icerik.com.

As can be seen in the diagram, when the same user switches from zeo.org to icerik.com, GA4 detects this user as two different people by default. We can see this through the client IDs:

- client at zeo.org ID: _ga=1234567_1234567

- client at icerik.com ID: _ga=1111111_1111111

This causes significant problems with your analytics data:

- Your unique user count is overstated

- You cannot follow transformation journeys correctly

- You cannot fully understand user behavior

Cross-domain tracking solves this problem by ensuring that the same client ID is used in both domains. This way:

- When the user switches from zeo.org to icerik.com

- Client ID (_ga=1234567_1234567) in the first domain is retained

- Both domains send data to the same GA4 property

- User journey can be tracked continuously

Domain and Subdomain Concepts in GA4 

One of the most confusing concepts in cross-domain tracking is the concept of subdomain. Google Analytics 4 treats subdomains as the same website if they are installed in the same property. This means that you do not need to do any extra setup for subdomain migrations.

As shown in the diagram below:

- zeo.org: Main domain

- blog.zeo.org: Subdomain (subdomain)

Subdomain Tracking:

- Automatic

- No additional configuration required

- Client IDs are shared automatically

- Example: blog.zeo.org → zeo.org

Cross Domain Tracking:

- Requires manual installation

- Domain list must be defined

- Special parameter usage required

- Example: zeo.org → farklidomain.com

How to Setup Google Analytics 4 Cross Domain Tracking?

As a result of my explanations above, we have understood when cross-domain setup is needed and when it is not needed. Now let's continue with the scenario we need and perform cross-domain setup together in GA4.

Let's assume that our first scenario is valid, i.e. zeo.org and icerik.com are actually the same website for us and we want the client IDs to remain the same in user transitions. Accordingly, we opened our Google Analytics 4 property installed on both sites.

Step-by-Step Installation

1. Access to Admin Panel

- Go to Admin section in GA4

- Select the relevant property from the Property column

2. Data Streams Settings

- Select “Data Streams” from the left menu

- Find your web data stream and click on it

3. Domain Configuration

- Click on “Configure Tag Settings”

- Find the “Configure your domains” option

- Click on the “Add domain” button

4. Domain List Creation

- Add both of your domains as below. You can change the match type options according to your scenario, the “Contains” condition is sufficient for my scenario.

- After adding the domains, we can finalize the process by saying “Save”.

URL Parameter After Cross-Domain Setup

After completing the cross-domain tracking setup, the “_gl” parameter is automatically added to the URLs when crossing between domains. This parameter carries the user's client ID and other important information. When we look at a sample URL structure: “https://icerik.com/sayfa?_gl=1*abc123*_ga*MTIzNDU2N18xMjM0NTY3”. The _gl parameter here consists of three parts: the version (1*), the control value (abc123), and the encrypted client ID (_ga* part).

This parameter protects the client ID (_ga=1234567_123456767) of the user who is transferred from zeo.org to icerik.com, so that the user is recognized as the same person on both sites. The parameter is added automatically, does not break the existing URL structure, and does not cause any SEO problems. 

For security purposes, the client ID is transported in encrypted format and can only be resolved on the domains you specify. To make sure that cross-domain tracking is working properly, you can check the transitions via Debug View and verify that client IDs are protected.