Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two different google tag manager accounts in same domain

Tags:

I have two google tag manager accounts one mine and another of third party website and I need to put these 2 in this third party website. I tried put two gtm scripts after body tag opening but I saw duplicated content of both accounts.

How can I do this? It's possible?

like image 466
Luiz Bim Avatar asked Jan 30 '14 19:01

Luiz Bim


1 Answers

This is because both GTM tags are using the default "dataLayer". See below:

<!-- Google Tag Manager --> <noscript><iframe... (window,document,'script','dataLayer','GTM-XXXX');</script> <!-- End Google Tag Manager --> 

Give one or both custom dataLayer names like so...(documentation):

<!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <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= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script’,'gtm1dataLayer','GTM-XXXX');</script> <!-- End Google Tag Manager --> 

After that you should see no duplicate events firing from either container.

like image 107
Bill Watts Avatar answered Sep 23 '22 00:09

Bill Watts