google analytics - GTM - One datalayer for multiple containers -


i use google tag manager several weeks now. had special request , have not found answer. possible several containers share same datalayer? in js code of 2 containers, tried give same name datalayer : result rather surprising ... tags in each containers executed twice.

specifically, try send event in 2 tags in 2 different containers. i'd avoid having maximum countless number call on onclick (hence idea of ​​having single data layer)

it possible use same datalayer multiple containers. possible include second container through first 1 (as tag).

but "all pages" rule fire once each container included on page. if have 3 containers, every tag fired on "all pages" fired 3 times. (the same true other events "gtm.js"...)

we found simple solution problem. include "page_loaded" event on every page , change "all pages" rule accordingly:

<script> var datalayer = []; </script> <!-- google tag manager --> <!-- end google tag manager --> <script> datalayer.push({"event": "page_loaded"}); </script> 

the page_loaded event fire once, independent number of containers used on page.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -