Google Tag Manager dataLayer within iframes

假如想象 提交于 2019-12-21 05:46:09

问题


I'm wondering if it's possible to 'sync' the dataLayer between an iframe and it's parent page.

The situation:

  1. I have a parent page with a GTM container and a hardcoded dataLayer.
  2. In that parent page I have an iframe with the same GTM container.

What I want to do is read the dataLayer in the parent from the iframe, ideally through the Tag Manager (Macros). The variable can be updated from the parent page, but the iframe should only read the data.

Is this possible? Google is pretty hazy about the issue and I can't really find a decent answer.


回答1:


Tracking across IFRAMEs with Google Tag Manager

I would suggest a different solution:

  1. parent page with GTM container
  2. datalayer events inside the IFRAME page
  3. only one GTM container per page

for pushing use the parent method:

parent.dataLayer.push({'event':'EVENT_NAME', 'var2':'ANOTHER_VARIABLE'});

Let me know if it worked for you.



来源:https://stackoverflow.com/questions/22382182/google-tag-manager-datalayer-within-iframes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!