Google跟踪代码管理器中的父类 [英] Parent Class in Google Tag Manager

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

问题描述

我找到了此Google跟踪代码管理器宏脚本( http://viget.com/advance/gtm#elementclass)来确定元素的父级是否具有特定的类值.

I found this Google Tag Manager macro script (http://viget.com/advance/gtm#elementclass) to identify if an element's parent has a specific class value.

function crawlByClassName () {
var el = {{element}};

while (el && el !== document.body && el.className !== 'INSERT CLASS NAME') {
    el = el.parentElement;
}

return el.className === 'INSERT CLASS NAME';
}

是否可以修改它以记录值,然后使用规则指定名称?还是有其他方法可以实现这一目标?

Is there a way to modify it to record the value and then use a rule to specify the name? Or is there a different way to achieve this?

推荐答案

感谢@kevintechie.您的方法可能有效.

Thanks @kevintechie. Your method might work.

我在这里找到了另一种方法 https://plus.google.com/100582165749296472339/posts/fa6iKeuF6ig

I was able to find another way here https://plus.google.com/100582165749296472339/posts/fa6iKeuF6ig

我可以将其用作宏:

function() {
return {{element}}.parentElement.className;
}

然后在规则中指定类名称.这意味着每个班级只有一个宏,而没有一个宏.

Then specify the class name in the rule. This means there's only one macro and not one for every class.

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

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