30

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?

3
  • Why are you using 2 different google tag manager containers? You can just add all the codes in one container. Feb 1, 2014 at 5:01
  • 5
    I'm using because one account I can't access and another is mine.
    – Luiz Bim
    Feb 2, 2014 at 16:41
  • This question's answers are old and no longer relevant except one: look at the answer from Yogesh Awdhut Gadade.
    – ktamlyn
    Sep 8, 2022 at 18:57

5 Answers 5

21

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.

3
  • 4
    Voted up for the link to the documentation and clear example, however it seems that Google recommends using a common datalayer on that very page.
    – Darvanen
    Oct 29, 2015 at 1:05
  • 14
    The specification was updated some 6 months ago. Currently, the only standing recommendation for multiple containers is to use the same dataLayer name for each container. That is the only way that it will work without conflicts.
    – Simo Ahava
    Dec 15, 2015 at 15:36
  • When using the same dataLayer variable we're seeing events fire multiple times though.. May 21, 2021 at 17:32
14

Updated information:

According to Google official document (https://developers.google.com/tag-manager/devguide?hl=en#multiple-containers)

It suggests:

  1. For the best performance of a page, keep the number of Google Tag Manager containers on the page minimal.
  2. If you use more than one container on a page, implement the container snippets with a common data layer object.
  3. Using more than one data layer can cause some triggers to stop working and could have other implications. So don't rename the data layer for a subset of containers on the page.
  4. You can, if necessary, rename the data layer for all containers on the page.
  5. Avoid implementing a Google Tag Manager container through a custom HTML tag in another Google Tag Manager container

For more details and example refer to this official page link: https://developers.google.com/tag-manager/devguide?hl=en#multiple-containers

2
  • 1
    This appears to be the only remaining relevant answer.
    – ktamlyn
    Sep 8, 2022 at 18:58
  • The section regarding use of multiple containers appears to have been removed from the linked article.
    – Jeemusu
    May 11, 2023 at 4:47
4

There should be no issues with multiple GTM containers on the same page. Unless you have duplicate codes in the containers which are double firing pixels. You can add those containers after the opening body tag.

To check what is firing on the entire page. Download firebug for firefox and add the "omnibug" extension. The omnibug extension should be in the firefox firebug window when you open it.

When you go the omnibug in the firefox panel, you will see EVERYTHING THAT IS FIRING!

If there are duplicate tags firing in the omnibug box, then you can check the details of the event and figure out which specific tag and delete them from the GTM container that you own.

0
3

Google tells us that you should not use two tag managers on one site. Google Support:

Multiple installations of Google Tag Manager detected

We suggest you place only 1 instance of the GTM snippet on a webpage. Multiple GTM snippets don"t work well with each other
Multiple GTM snippets don"t work well with each other because of which the tag added via GTM may not always fire correctly.

Place only 1 instance of the GTM snippet on a webpage

https://support.google.com/tagassistant/answer/3207128?hl=en#multiple_tags

2
  • 2
    is this still valid? the link seem to work, but does not redirect to a specific section
    – Theo
    Nov 15, 2018 at 10:52
  • This answer is NOT relevant to the question, and appears WRONG as of this comment. You can have multiple configs, but you need only load one script tag with the first config. The only thing you would have to do today is remove the second script tag.
    – ktamlyn
    Sep 8, 2022 at 18:55
0

Seems possible to find any answer you like for this. According to tag manager developer guide you can add multiple containers but you should use the same datalayer.

https://developers.google.com/tag-manager/devguide#multiple-containers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.