Reputation: 215
Assuming I have a couple of <amp-video>
elements and I want to send player events of trigger video-play
[https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/amp-video-analytics.md] and I want to send the data-vars as query param for the in house analytics.
the click event is sent as expected with all query params filled. However, the video-view event is sent with all query params except for the video_id.
any suggestions?
for example: `
<amp-video class="myVideo" autoplay loop width="640" height="360" layout="responsive" data-vars-video-id="123456" poster="...">
<source src="....mp4" type="video/mp4" />
<div fallback>
<amp-img src="...jpg" width="16" height="9" layout="responsive"></amp-img>
</div>
</amp-video>
...
<amp-analytics>
<script type="application/json">
{
"requests": {
"event": "https://counter.exmple.io/_track?event=${eventType}&url=${canonicalUrl}&user=CLIENT_ID(ampCid)&video_id=${videoId}"
},
"triggers": {
"minVideoPlay": {
"on": "video-play",
"selector": ".myVideo",
"request": "event",
"vars": {
"eventType": "video-view"
}
},
"minClick": {
"on": "click",
"selector": ".myVideo",
"request": "event",
"vars": {
"eventType": "click"
}
}
},
"transport": {
"beacon": true,
"xhrpost": true
}
}
</script>
</amp-analytics>
`
Upvotes: 0
Views: 811
Reputation: 616
I took a look at the amp-analytics variables docs and I believe only click
and visible
events are able to consume data-vars-*
attributes at this time.
Variables as data attribute
For the following event types, variables can be passed as part of the element level data attribute
- visible
- click
Feel free to open a feature request at the AMP Project GitHub for data var substitution for analytics events other than click
and visible
. Another approach could be a feature request for the video id as a standard video analytics variable, since almost all videos have an ID, which could at least be the URL.
As a workaround for now you could create a separate video analytics trigger for each video id on the page and manually specify the id in the vars
block.
Upvotes: 0