Mastering Cross-Domain Tracking in GA4: A Simplified Approach

2024-01-04 | Article | Insights

"Simplified Cross-Domain Tracking in GA4: Boosting Accuracy in Analytics"

In the world of web analytics, tracking user behaviour across multiple domains has always presented a unique challenge. Google Analytics, a staple in website analytics, primarily relies on first-party cookies for user tracking. These cookies, like the commonly known _ga, are instrumental in understanding user interactions as they navigate within a single domain. However, when the user's online journey spans across distinct domains, tracking becomes more complicated.

This article delves into the concept of cross-domain tracking, offering a solution to this challenge, as well as providing insights on how to set it up effectively in Google Analytics 4 (GA4).

The Challenge of Tracking Across Multiple Domains

Google Analytics typically uses first-party cookies to track users. When a user lands on a website, a cookie is set, and in most cases the _ga is stored in the browser. As the user navigates from one page to another on the same domain the cookie info remains accessible.

However, the problem arises when a user's journey starts on domainX.com and ends on domainY.com. Due to the cross-domain policy, cookies created on the first domain cannot be shared with the second. As a result of that the user activity will result in two separate users and sessions in the reports. This situation, known as "self-referral," can lead to inaccurate data in the reports.

What is Cross-Domain Tracking?

The solution to this problem is cross-domain tracking, a workaround where we transfer the cookie information from the source domain to the destination domain, setting the same _ga cookie. In this way, the user is being tracked as the same user across multiple domains without interrupting the session.

Cross-domain tracking works only if both domains use the same GA4 measurement ID (i.e. same Data Stream) and it is not required in the case of subdomains, as _ga cookie will be written on the main domain by default. They are therefore available for all subdomains by default.

Set Cross-Domain Tracking in GA4

While in the predecessor Universal Analytics (UA) the cross-domain tracking was a combination of updating the code (gtag.js) and the Google Tag Manager (GTM) and configuring the UA property admin area, the setup for GA4 has been simplified and it is sufficient to configure the GA4 Data Stream tagging settings.

First, the user must have access to the administration area and select Data Streams in the property settings:

After selecting the correct web stream (not possible to set cross-domain tracking for apps) the user must configure the tag settings:

Final step is to configure the domains:

Define the list of domains to which cross domain tracking is to be applied:

Validate the setup

To validate the setup, the user needs to select a link from the domainX.com pointing to domainY.com, and if everything is set up correctly, the destination URL will be provided with a new URL parameter _gl followed by several parameters.

Each one of those parameters has a specific role:

  • _gcl_aw: Google Ads Click identifier
  • _ga: Google Analytics Client identifier
  • _ga_xxxxxxxx: Google Analytics 4 session cookie
  • _fplc: Cross-Domain cookie in case of server-side GTM setup

If the _gl parameter is not available in the destination URL, something is not set correctly with regard to the automatic link decoration.

It is important to check again the validity of the domains listed in the admin area and whether all the pages are tagged with the same GA4 measurement ID.

Even If they are set up properly, it is possible that you miss the _gl parameter after a redirect or, even worse, that the link you are testing does not point directly to the destination domain even if it is redirected at the end, so the initial link is not decorated at all.

In any case, even if the _gl is available, it is important to validate that the value of the _ga cookie is the same across both domains.

Final Words

Setting up cross-domain tracking in GA4 is easier than before with UA, as you do not have to worry about parameters such as "allowLinker" or "Auto Link Domains." Instead, only the domains need to be listed in the GA4 admin area.

GA4 represents a shift toward reducing the code or GTM configuration and putting more emphasis on the GA4 interface. However, GTM still plays a critical role and it is an excellent tool to have full control of tracking.

Do you need more Info?

Contact