Mugo Web main content.

Cross-domain tracking in Google Analytics: Excluding domains in GA4 and GTM

By: Peter Keung | August 16, 2022 | google analytics, Business solutions, and GA4

If you manage one of the millions of websites affected by the Google-mandated migration from Universal Analytics (UA) to Google Analytics 4 (GA4), you might be following the best practice of simultaneously running UA and GA4 scripts until you’re ready to adopt GA4 fully. One of the analytics features that needs special attention is cross-domain tracking.

What is cross-domain tracking, and why should you care?

If your web properties span multiple subdomains or domains, even if you put the same script on all your websites, Google Analytics will treat visits in the same session to multiple domains as multiple sessions. You need to configure cross-domain tracking if you want to use a single session as a user transitions between domains.

When you’ve configured cross-domain tracking, Google Analytics will automatically append a GET parameter named “_ga4” to links from one site to another. The challenge with running UA and GA4 simultaneously is that only one set of configuration settings can be applied at once. One of these configuration settings is the list of domains to include and exclude, and it appears that the GA4 settings take precedence over UA.

Excluding domains in GA4 and GTM

Suppose that you want to treat visits to these domains as part of the same user session:

  • mugolibrary.ca and any subdomains
  • mugo.ca and all subdomains except for library.mugo.ca

With UA and GTM, you could configure these domains and a couple of other cross-domain tracking settings within the variable type “Google Analytics Settings”:

cross_domain_tracking.jpg

Unfortunately, at the moment, these settings cannot be configured for GA4 within GTM, thus losing out on the preview and versioning features (among others) of GTM. For now, you must make the settings change within GA4. Note also that the “Use Hash as Delimiter” and “Decorate Forms” options are not available within the GA4 interface. To configure the domains, do the following:

  • Within the Analytics interface for the GA4 account, visit the Admin section and select “Data Streams”
  • Select the data stream for your website
  • Under “Google tag”, select “Configure tag settings”
  • Select “Configure your domains”

You can use the “Contains” match type to include mugolibrary.ca and any subdomains. To include all mugo.ca subdomains except for library.mugo.ca, you’ll need the “Matches RegEx” match type and the following pattern, which uses a negative lookahead:

^(?!library).*\.mugo\.ca

configuration_settings.jpg
loading form....
Thanks for reaching out. We will get back to you right away.

Comments

blog comments powered by Disqus