Chr*_*oph 7 google-tag-manager
我想在 GTM 中创建一个变量,它返回最接近的元素。在 javascript 标签中可以这样完成:
function() {
return function(target, selector) {
while (!target.matches(selector) && !target.matches('body')) {
target = target.parentElement;
}
return target.matches(selector) ? target : undefined;
}
}
Run Code Online (Sandbox Code Playgroud)
为了使我们的网站符合 CSP 要求,不允许使用自定义 JS 标签,我们应该创建 gtm 变量模板。
GTM 模板的问题是您无法传递 {{click element}} 所以我正在寻找一种如何从数据层访问 gtm.click 并执行最接近的函数的方法。 https://www.simoahava.com/analytics/custom-templates-guide-for-google-tag-manager/#restrictions-to-what-type-of-data-you-can-handle
我能够通过注入脚本来做到这一点的唯一方法吗?我宁愿使用 gtm 模板 api 之一来解决此问题。
| 归档时间: |
|
| 查看次数: |
227 次 |
| 最近记录: |