Cross-domain tracking with Google Analytics

1. Using Google’s gtag.js tracking script

Cross-domain tracking using gtag.js is quite simple and simply requires a minor addition of code to your existing gtag.js script.

Specifically, adding this section of code:

'linker': {
  'domains': ['exampledomain1.com', 'myotherdomain.com', 'myaccount.thrivecart.com'], // Change these to point to your multiple domains
  'accept_incoming': true
}

Your total gtag.js code would then look like:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=YOURPROPERTYIDHERE"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'YOURPROPERTYIDHERE', { // Paste your property ID here from the example gtag script - note it ALSO goes above!

  'linker': {
    'domains': ['mydomain.com', 'myaccount.thrivecart.com'], // Change these to point to your multiple domains
    'accept_incoming': true
  }

});
</script>

Remember that “YOURPROPERTYIDHERE” would be replaced with your own tracking ID from Google AND the domains would list your actual websites and ThriveCart subdomain.

You would then paste this code on both your websites AND in your ThriveCart product settings. As per this helpdesk article.

2. Using Google’s analytics.js tracking script

See the video below for a tutorial on Cross-domain tracking and Google’s analytics.js tracking code.

In the video below we take a look at setting up cross-domain tracking for Google Analytics using the analytics.js tracking code.

Resources:

  • Get the analytics.js tracking code – click here.
  • Review Google’s official documentation – click here.
  • Google Tag Assistant Chrome extension – click here.
  • Google Analytics debugger Chrome extension – click here.

Please note that we are not responsible for the above browser extensions, we do not provide support, nor are we responsible for any misuse or issues arising from using them.

Related Articles