我知道如何在amp-analytics标记内设置基本点击跟踪。但是,是否可以在<amp-list>
?
<amp-analytics type="googleanalytics">
<script type="application/json">
{
"vars": {
"account": "UA-XXXXX-Y"
},
"triggers": {
"trackClickOnMyDynamicItem" : {
"on": "click",
"selector": "#myElementInAmpList",
"request": "event",
"vars": {
"eventCategory": "someCategory",
"eventAction": "someAction",
"eventLabel": "someDynamicLabelRetrievedFromAmpList"
}
}
}
}
</script>
</amp-analytics>
答案 0 :(得分:0)
你可以使用data-vars- *来做到这一点 例如:
<amp-list>
<template type="amp-mustache">
<a href="{{ Url }}" id="myElementInAmpList" data-vars-product-name ="{{ ProductName }}">
</template>
</amp-list>
在跟踪脚本中,您可以:
<amp-analytics type="googleanalytics">
<script type="application/json"> {"vars": {
"account": "UA-XXXXX-Y"},
"triggers": {
"trackClickOnMyDynamicItem" : {
"on": "click",
"selector": "#myElementInAmpList",
"request": "event",
"vars": {"eventCategory": "someCategory",
"eventAction": "someAction",
"eventLabel": "${productName}" //this will be dynamic
}
}
}
}
</script>
</amp-analytics>