我想在我的AMP html页面上点击链接时使用谷歌分析跟踪事件。此外,我想在跟踪此事件时将链接(href)作为eventLabel传递。有没有办法将链接URL设置为data- *属性,然后可以将其传递给谷歌分析事件跟踪脚本。或者还有其他方法可以做到这一点。
这是非常标准的事情,但Google Analytics for AMP页面并不涵盖它。
答案 0 :(得分:3)
I think what you are asking for was recently made available here.
basically, you can use code like
<span id="test1" class="box" data-vars-event-label="22"> Click here </span>
and then use the value in the configuration as ${eventLabel}
答案 1 :(得分:2)
似乎这是可能的。 Google Analytics现在支持AMP extended component。
事件是用户与内容的互动,可以独立于网页或屏幕加载进行跟踪。现在可以监控Event tracking clicked links,如:
..,
"trackAnchorClicks": {
"on": "click",
"selector": "a",
"request": "event",
"vars": {
"eventId": "42",
"eventLabel": "clicked on a link"
}