0

How can I pass a dataLayer variable from one domain to another domain using Google Tag Manager? Both domains use the same GTM container. Thank you.

ImASkuller
  • 39
  • 5

1 Answers1

0

Whether the domains use the same GTM is not important. What's more important is whether they're the same TLD (top-level domain), or different TLDs.

If it's the same TLD, then passing a variable would be easily done via a cookie. If it's a different TLD, then you could use a third party cookie. However, there has been a world-wide witch hunt after the third party cookies, due to which it's not a good idea to use them anymore.

As the result, there are two fiable options to pass variables between TLDs, whether through GTM or just front-end.

  1. Employ backend. Make the backend keep and pass the variable. Based on its ability to sync sessions of users on different TLDs, if the backend is the same on all TLDs.
  2. Pass your variables by appending them to the url on navigations from one TLD to the other. Once GTM on the other side sees them, it can store them in a cookie and clean urls from the query params to make it look neater.

The latter option is how GTM (and GA4) does cross-domain tracking by default.

BNazaruk
  • 6,300
  • 3
  • 19
  • 33