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

Published: 22 March 2023

Updated: 17 July 2023

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.

    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

    1 September 2023

    How Marketing Teams Can Take Advantage of Generative AI

    Generative AI is a game-changer for marketing. Discover how you can use this technology to create more personalized customer experiences and drive more conversions.

    Learn more

    31 July 2023

    10 Tips for Marketing Male Supplements with Social Media

    Discover the best way to promote your male supplement company with our comprehensive guide. Learn how to use social media to promote your products and generate leads.

    Learn more

    20 July 2023

    How Marketers Can Use GA4 to Improve Campaign Performance

    Study our guide to GA4 for marketers and learn how to track your marketing performance, measure your ROI, and make better decisions.

    Learn more

    14 July 2023

    Understanding Data Filters in Google Analytics 4

    Want to get more out of your Google Analytics 4 data? Learn how to use GA4 filters to see the data that matters most to you.

    Learn more

    5 July 2023

    How to Set up Event Tracking in Google Analytics 4

    Learn how to set up event tracking in Google Analytics 4, track user behavior on your website or app, and use this data to improve your marketing campaigns and website performance.

    Learn more

    30 June 2023

    The Ultimate GA4 Handbook: Your Complete Guide to Understanding GA4

    Discover the ultimate guide to Google Analytics 4. Seamlessly transition from Universal Analytics to GA4 and unlock its full potential. Download the free handbook now!

    Learn more

    23 June 2023

    How to Use Google Analytics 4 to Grow Your Small Business

    Want to know how to use Google Analytics 4 to grow your small business? This article will show you how to set up GA4, track your key metrics, and use the data to make informed decisions.

    Learn more

    13 June 2023

    Understanding Enhanced Measurement in GA4

    Learn how to use Enhanced Measurement in Google Analytics 4 to collect more data about your users and improve your marketing and business decisions.

    Learn more