正则表达式 Table 查找不适用于单击元素变量
Regex Table Lookup not working with Click Element variable
我创建了一个正则表达式查找 table 变量来根据包含特定字符串的点击元素输出文本。但是,尽管字符串肯定在 Click 元素中,但该变量显示为 null。有人可以帮忙吗?
Here is my regex lookup table variable
Here is the debug window showing null (the Action field is where the regex table variable should populate)
Here is the full tag that contains the variable
Here is the trigger for the tag
我尝试了 Click Element 中的各种不同字符串,但没有成功。
标签的触发器基于相同的字符串,并且触发器有效,这只会增加我的困惑。
我感觉问题应该很明显了,但是我很茫然
我也为此苦苦挣扎,直到我意识到“Click Element”实际上是一个对象,而不是字符串。它基于 datalayer
中的 gtm.element
。
因此,为了做到这一点,您需要创建一个自定义数据层变量,以更准确地定位特定的子键。
要明白我的意思,请在新选项卡中打开 link,然后在浏览器控制台中输入 datalayer
,然后按回车键。您会看到如下内容:
3:
event: "gtm.click"
gtm.element: a#mylinkclass.my-class.something.else
accessKey: ""
ariaAtomic: null
ariaAutoComplete: null
ariaBusy: null
ariaChecked: null
ariaColCount: null
ariaColIndex: null
etc....
Screenshot of chrome inspector console showing datalayer children
因此,您必须创建自定义变量来定位您想要的键。例如,您使用 gtm.element.className
创建的数据层变量将为 return my-class something else
for link <a href="/my-link-here/" class="my-class something else" id="mylinkclass">Link Text</a>
.
使用这种方法,我能够创建正则表达式查找 table,就像您尝试做的那样。
这里有一个 post 对上述一些内容进行了更详细的介绍:
https://www.analyticsmania.com/post/click-element-variable-in-google-tag-manager/
我创建了一个正则表达式查找 table 变量来根据包含特定字符串的点击元素输出文本。但是,尽管字符串肯定在 Click 元素中,但该变量显示为 null。有人可以帮忙吗?
Here is my regex lookup table variable Here is the debug window showing null (the Action field is where the regex table variable should populate)
Here is the full tag that contains the variable
Here is the trigger for the tag 我尝试了 Click Element 中的各种不同字符串,但没有成功。
标签的触发器基于相同的字符串,并且触发器有效,这只会增加我的困惑。
我感觉问题应该很明显了,但是我很茫然
我也为此苦苦挣扎,直到我意识到“Click Element”实际上是一个对象,而不是字符串。它基于 datalayer
中的 gtm.element
。
因此,为了做到这一点,您需要创建一个自定义数据层变量,以更准确地定位特定的子键。
要明白我的意思,请在新选项卡中打开 link,然后在浏览器控制台中输入 datalayer
,然后按回车键。您会看到如下内容:
3:
event: "gtm.click"
gtm.element: a#mylinkclass.my-class.something.else
accessKey: ""
ariaAtomic: null
ariaAutoComplete: null
ariaBusy: null
ariaChecked: null
ariaColCount: null
ariaColIndex: null
etc....
Screenshot of chrome inspector console showing datalayer children
因此,您必须创建自定义变量来定位您想要的键。例如,您使用 gtm.element.className
创建的数据层变量将为 return my-class something else
for link <a href="/my-link-here/" class="my-class something else" id="mylinkclass">Link Text</a>
.
使用这种方法,我能够创建正则表达式查找 table,就像您尝试做的那样。
这里有一个 post 对上述一些内容进行了更详细的介绍:
https://www.analyticsmania.com/post/click-element-variable-in-google-tag-manager/