Josh
Josh

Reputation: 180

GTM cross domain tracking

I am trying to do a cross domain GTM, but have a question. I have the GTM and GA in domain1.com and just GTM in domain2.com. Is it possible to track variables by using just the container? or do I need a GA in both domains?

GTM in domain1.com and domain2.com

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js? 
id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-xxxx');</script>
<!-- End Google Tag Manager -->

Upvotes: 0

Views: 537

Answers (1)

Eike Pierstorff
Eike Pierstorff

Reputation: 32760

The GTM container itself does not track anything. You need GA on both domains. However, as you are using the same container on both sites you can use the same Analytics tag within the container - you do not need a tag per domain, and you do not need Analytics code outside your container (which might be what you are actually asking).

In your GA settings variable (or in your GTM Google Analytics tag, if you have "enable override settings variable" checked) go to the advanced settings, look for cross domain tracking and enter a comma separated list of your domains in the "autolink domains" field (documentation here). This will decorate hrefs and forms automatically with the linker parameter (and set Analytics to use the value from the parameter). This does not cover a few edge cases (like redirects via Javascript), but usually it's good enough.

Upvotes: 2

Related Questions