iframe中的Google跟踪代码管理器dataLayer [英] Google Tag Manager dataLayer within iframes

查看:344
本文介绍了iframe中的Google跟踪代码管理器dataLayer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以在iframe和它的父页面之间'同步'dataLayer。

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

情况:


  1. 我有一个包含GTM容器和硬编码dataLayer的父页面。

  2. 在该父页面中我有一个iframe GTM容器。

我想要做的是从iframe读取父级中的dataLayer,理想情况是通过跟踪管理器(宏) 。可以从父页面更新变量,但iframe应该只读取数据。

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.

这可能吗? Google对此问题非常朦胧,我无法找到合适的答案。

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

推荐答案

使用Google跟踪代码管理器跟踪IFRAME

Tracking across IFRAMEs with Google Tag Manager

我建议采用不同的解决方案:

I would suggest a different solution:


  1. 包含GTM容器的父页面

  2. IFRAME页面内的数据层事件

  3. 每页只有一个GTM容器

推送使用方法:

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

让我知道它是否适合你。

Let me know if it worked for you.

这篇关于iframe中的Google跟踪代码管理器dataLayer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆