GA4 Cross Domain Tracking: How to Track Multiple Domains and Sub Domains

Cross Domain Tracking in GA4 or Universal Analytics (GA3 or old Google Analytics) allows you to track multiple domains in one Google Analytics property and treat the user journey as if it is one domain.

Why do you need cross-domain tracking?

By default when you track two domains in one property of google analytics, they are treated as two different sites. Let's say, I have two domains, Optizent.com and Gapremium.com, these two are entirely different domains. Even if I combine them in one Google Analytics property the user session will be contented separately when the user goes from one domain to another. So if I user lands on optizent.com and then clicks on a link on Optizent.com that takes the user to GAPremium.com then there Google Analytics will report 2 sessions, since each domain will drop its own unique cookie for that user. However, if I want to treat that session as only one session then I will need to enable cross-domain tracking.

What does cross-domain tracking do?

Cross-domain tracking allows the user and session information to be passed from one domain to another and hence combining the user journey under one session.

Google Analytics uses first-party cookies to identify each user and session to a website/domain.

By default, without cross-domain tracking, new cookies are set for each domain a user visits. Analytics count these new cookies with new identifiers as separate users with separate sessions.

By using cross-domain tracking, the same cookie information is passed from one site/domain to another via a URL parameter identified by the key _gl:, thus attributing the visit to the same user as the user goes from one domain to another.

How do I add another domain to Google Analytics 4 for cross-domain tracking?

To set up cross-domain tracking follow these steps

  1. Go to the admin panel of the GA4 property.
  2. Click on Data Streams (under property)
  3. Click on the data stream that you want to enable cross-domain tracking for.
  4. On the next screen (streams details), scroll to the bottom and click on "More tagging settings"
  5. On the next screen (More tagging settings), click on "Configure Your Domains"
  6. On the next screen, click on "Add Conditions" and add your domains using one of the match types i.e. contains, exactly matches, regex, begins with or ends with.
  7. Once done, hit "Save"
  8. Your cross-domain tracking is ready. Make sure to use the same Measurement ID for both sites.

 

How do I know if cross-domain tracking is working?

Go to one of your websites (let's call it "site A"), click on the link to the other website (let's call it "Site B"). When you land on Site B check the URL, it should contain the _gl= parameter. That parameter indicates that GA is passing information about users from one site to another.
You can also check if the _ga cookie in both of the sites, it should contain the same value.
If cross-domain tracking is working properly, you should see the pageview(s) and events from both domains in the report. If cross-domain tracking isn't working, you'll only see the pageview(s) from one domain.
You can use the GA4 Debug view to check if all the events and user properties are coming as expected.

Leave a Reply

Your email address will not be published. Required fields are marked *