AMP 分析 - link 跟踪,跟踪哪些 links/data 属性被点击

AMP analytics - link tracking, track which links/data attributes were clicked

我已经实施了 AMP 分析和一些事件,它工作正常,但我想知道如何捕获点击的目的地 link。

如果我有这样的link:

<a rel="nofollow,noopener" data-item="ShopName" data-product="ProductName" class="link-price" target="_blank" href="ShopURL">ShopName</a>

我是这样追踪的:

"article prices": 
            {
                "on": "click",
                "selector": ".link-price",
                "request": "event",
                "vars": 
                    {
                        "eventCategory": "Prices",
                        "eventAction": "<I WOULD LIKE SHOPNAME HERE",
                        "eventLabel": "<I WOULD LIKE PRODUCTNAME HERE>"
                    }                   

            }

我很想把一些 javascript 放在那里,但是 javascript 是不允许的。

是否可以跟踪数据属性和 url?

在HTML中使用数据属性:

data-vars-my-label="ProductName1"

和您的配置 JSON:

"vars": {
    "event_label": "${myLabel}",
    ...

https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/analytics-vars.md