Reputation: 1563
I have implemented AMP analytics and a couple of events, it's working fine but I'm wondering how I could capture the destination of a clicked link.
If I have a link like this:
<a rel="nofollow,noopener" data-item="ShopName" data-product="ProductName" class="link-price" target="_blank" href="ShopURL">ShopName</a>
I track it like this:
"article prices":
{
"on": "click",
"selector": ".link-price",
"request": "event",
"vars":
{
"eventCategory": "Prices",
"eventAction": "<I WOULD LIKE SHOPNAME HERE",
"eventLabel": "<I WOULD LIKE PRODUCTNAME HERE>"
}
}
I would be tempted to put some javascript in there but javascript is not allowed.
Is there any possibility to track data attributes and urls?
Upvotes: 2
Views: 543
Reputation: 286
Use data attributes in HTML:
data-vars-my-label="ProductName1"
and your config JSON:
"vars": {
"event_label": "${myLabel}",
...
See https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/analytics-vars.md
Upvotes: 1