1. Home
  2. Custom Scripts & Codes
  3. Cross-domain tracking with Google Analytics

Cross-domain tracking with Google Analytics

This is example code that you can use on your website so that you can set up cross-domain tracking for users coming from your website to ThriveCart (and then back to your site if you’re using a custom success page).

This will allow Google to track the user as a single session and aid with referral tracking in Google Analytics.

If you’re specifically using Google Tag Manager, then the process may be slightly different and we recommend checking GTM’s help on setting up cross-domain tracking.

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>
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


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

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.


  • 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.

Updated on April 4, 2022

Was this article helpful?

Related Articles