Home Blog Area Analytics

How to Set up Cross-Domain Tracking in Google Analytics 4?

How to Set up Cross-Domain Tracking in Google Analytics 4?

Cross-domain tracking is an essential part of any successful digital marketing strategy. It allows a website visitor’s activity on multiple domains or subdomains to be tracked as a single session, providing more accurate data and insights into how visitors navigate your website. And if you are familiar with cross-domain tracking in UA, most of the configuration is done on the code level (e.g., in gtag.js) or in GTM (GA tags). Because of that, many marketers and web analysts felt confused about what to do and where. In this guide, we’ll show you how to configure cross-domain tracking in Google Analytics 4.

Table of Contents:

  1. The Problem of Domain Tracking
  2. What is Cross-Domain Tracking in GA4?
  3. How Does Cross-Domain Tracking Work in GA4?
  4. Cookies and Cross-Domain Tracking
  5. How to Set up Cross-Domain Tracking in GA4?
  6. How Do You Know that Cross-Domain Tracking is Enabled?
  7. URL Redirects
  8. Final Words
  9. The Problem of Domain Tracking

    If your web property spans across multiple domains or subdomains, Google Analytics will consider visits in the same session to multiple domains as multiple sessions. So you need to configure cross-domain tracking if you’d like to use a single session as a user transitions between domains. Once you’ve done it, Google Analytics will automatically add a GET parameter “_ga4” to links from one site to another. The challenge with running GA4 and UA simultaneously is that only one configuration set can be applied simultaneously. One of these configurations is the list of domains to include and exclude, and the GA4 settings surpass UA.

    What is Cross-Domain Tracking in GA4?

    Before proceeding with the configuration guide, let’s say a few words about cross-domain tracking. If you’re already familiar with GA4 and have experience with multiple domains, skip this section and move on.

    Cross-domain tracking in Google Analytics 4 (GA4) is a method for maintaining the same user identity across multiple domains. This ensures that all user activity from various domains is accurately linked to the same individual and reported similarly. Cross-domain tracking makes it possible to track website interactions regardless of where customers go next, enabling businesses to understand customer behavior better and improve their overall user experience. This information allows companies to develop effective marketing strategies based on real data insights.

    By proceeding further you agree to our Privacy Policy

    How Does Cross-Domain Tracking Work in GA4?

    If a visitor travels from domain 1 to domain 2, GA4 will pass a specific parameter to the domain 2 URL. With the help of this parameter, Google Analytics on domain 2 will update GA4 and understand that it’s one person navigating between two websites.

    Note that if you track different websites that belong to the same domain, Google Analytics 4 will handle them automatically. And you don’t need cross-domain tracking for that.

    Cross-domain tracking process

    Cookies and Cross-Domain Tracking

    When there’s consent, Google Analytics uses first-party cookies to set IDs for each unique session.

  • With cross-domain measurement, cookies retain the same as IDs. They’re passed from one domain to another via a URL parameter when a user navigates between domains through a link or a form. As a result, Analytics recognizes one user and one session.
  • Without cross-domain measurement, new cookies with new IDs are created for each domain a user visits. As a result, a single user that visits different root domains on the same device will be identified separately (two users and two sessions instead of one user and one session).

Note that this setup isn’t required for subdomains as they share the same cookies with the root domain (except when you change the default cookie domain configuration).

How to Set up Cross-Domain Tracking in GA4?

In the case of Google Analytics 4, setting up cross-domain tracking has been made simple compared to Universal Analytics, where hardcoded tagging was required. Now it can be configured in the Admin section.

Note that you’ll need an Editor role to set up cross-domain measurement.

  1. Navigate to your GA4 property and click Data streams in the Property column
  2. GA4 property

  3. Once a new overlay appears, select Data Streams
  4. GA4 data streams

  5. On the right side of your screen, you’ll see all data streams linked to your account; these are your websites and applications
  6. Linked data streams GA4

  7. Select the necessary data stream and click Configure tag settings
  8. Configure tag settings GA4

  9. Next, choose to Configure your domains
  10. Configure your domain settings GA4

  11. Here you should Include all domains for the cross-domain setup by clicking Add condition
  12. Add conditions GA4

  13. Select Contains in Match type and add your domain to Domain box
  14. Match type configurations GA4

  15. Then repeat the process starting from Add condition to incorporate your second domain and click Save

Adding conditions GA4

If you have cross-domain tracking in Universal Analytics, you should verify that the same domains are tracked in GA4.

How Do You Know that Cross-Domain Tracking is Enabled?

To verify if cross-domain measurement is working properly, follow the next steps:

  • Open the website page that contains a link or a form that points to a domain your set up for cross-domain measurement
  • Click the link or submit the form to go to the destination domain
  • Make sure that the URL in the destination contains the linker parameter _gl

Another way to test your configuration is to install and enable the Google Analytics Debugger and go to the DebugView of GA4.

DebugView GA4

Then go back to your first website and reload the page. You’ll see a page_view event that would have occurred around the same time you visited the page.

Page_view GA4

Click on it, and details related to the event will pop up. Under Parameters, take note of the following:

  • ga_session_id
  • page_location

GA4 parameters

The ga_session ID is a unique parameter, and it must remain the same when you click a link that sends you to the other domain. The page_location parameter should be for the second domain. These are the results you should be looking for.

URL Redirects

If the destination page redirects or doesn’t support arbitrary query parameters, the parameter _gl might be removed from the URL even if it was added by Google Analytics on the previous page. To confirm this is happening to your website, check the network requests made by the previous page using the Chrome Developer Tools. Configure your website to preserve the parameter _gl in redirects to fix this issue.

Final Words

By following these steps carefully, anyone can set up cross-domain tracking in Google Analytics 4 (GA4). Doing so will give website owners valuable insights into how their visitors navigate across different domains and subdomains, allowing them to optimize their digital marketing efforts more effectively than ever. As always, if there are any questions about setting up cross-domain tracking in GA4, please feel free to reach out — we would love to help!

Enable Cross-Domain Tracking in GA4

Get in touch

Got a question? We'd love to hear from you. Send us a message and we'll respond as soon as possible.

    By clicking submit, you agree to our Privacy Policy

    Latest Insights

    Get the tips from our experts to optimize and scale your campaigns

    13 June 2024

    Prevent Data Loss: Set Up BigQuery Error Notifications

    BigQuery has gained significant popularity and is increasingly utilized in numerous projects. Google’s cloud-based data warehouse solution is known for its scalability, speed, and ability to handle large datasets efficiently. As more organizations integrate BigQuery into their data processing and analytics workflows, robust monitoring and alerting mechanisms are essential. Implementing alerts for jobs that encounter […]

    Learn more

    30 May 2024

    How To Create A Meaningful Ecommerce Analytics Dashboard: A Step-by-step Guide

    Are you drowning in a huge amount of e-commerce data? There’s no other way to escape it if you want your e-commerce store to succeed. However, you can make analyzing your data much more enjoyable and effective. The key is to present e-commerce data analytics visually. Data visualization plays a big role in data-driven decision-making. […]

    Learn more

    28 March 2024

    Navigating the Data Deluge: Prioritizing Key Metrics in the Age of Google Analytics 4

    With the advent of Google Analytics 4 (GA4), the key business challenge becomes not collecting data but discerning what truly matters in the sea of data. 64% of marketing executives believe data-driven marketing is crucial to success in a hyper-competitive global economy. By prioritizing key metrics and avoiding the trap of tracking everything, businesses can […]

    Learn more

    3 January 2024

    How to Create a Viable First-Party Data Strategy in 2024?

    Discover the 9 key steps to build a first-party data strategy that maximizes customer data and enhances your marketing efforts.

    Learn more

    27 December 2023

    How To Create a Seamless Customer Experience to Win More Returning Clients

    Want customers hitting a repeat button? Learn the secrets to building a seamless customer experience that keeps them coming back for more.

    Learn more

    30 November 2023

    Maximize Your Data Retention in Google Analytics 4 (GA4) 

    Learn how to manage data storage and protect privacy with GA4 data retention settings.

    Learn more

    24 November 2023

    How to Read and Interpret Google Analytics 4 Reports to Drive Business Success

    Get to know how to read Google Analytics 4 reports to uncover customer insights, optimize marketing strategies, and drive business growth.

    Learn more

    11 November 2023

    How to Preserve Google Analytics Historical Data

    Fearing to lose your Google Analytics’ historical data? Don't worry! This guide will show you four ways to save data during the UA-to-GA4 migration.

    Learn more