AMP Story Analytics
As per the latest update on analytics regarding AMP Stories, we had updated the code according to https://blog.amp.dev/2019/08/28/analytics-for-your-amp-stories/
Concern 1: There is an error in the console ["on" and "request" attributes are required for data to be collected].
If we add "request":"event" after "on":"story-page-visible/story-last-page-visible", Example : {"on": "story-page-visible", "request": "event", then there is no such console error, So it right to add "request": "event"?
Concern 2: What about the pageview request?
Do we need to add "trackPageview":{"on":"visible","request":"pageview"}, in "triggers" for pageview request.
/to @Enriqe
Hey @AutadeJS, thanks for reaching out.
There is an error in the console ["on" and "request" attributes are required for data to be collected].
Yes, as per the general amp-analytics trigger documentation, both on and request properties in the config are required:
- on (required) The event to listen for.
- request (required) Name of the request to send (as specified in the requests section).
Do we need to add [...] in "triggers" for pageview request.
If you want to track the events when a page is visible, you should use the story-page-visible trigger, as shown in the blog post you mentioned and in the official amp-story analytics documentation.
"storyProgress": {
"on": "story-page-visible",
"request": "pageView",
},
Closing for now but feel free to let us know if you have any other questions!
Thank you so much
Hi Enriqe
As per the latest update on analytics regarding AMP Stories, we had updated the google analytics code which you check on https://vacayholics.com/big-ben-facts, but we are not receiving any data, not even the page view. What I found that in DevTool> Network > Header > Query String Parameters > tid : it is blank there is no Google Analytics Tracking Id. This is the code what we implemented which you will find in view-source:https://vacayholics.com/big-ben-facts
Can you once check the code where the implementation is according to the latest update ?
Hi @Enriqe As per the latest update on analytics regarding AMP Stories, we had updated the google analytics code which you check on https://vacayholics.com/big-ben-facts, we have also created the Dashboard as per the guidelines are given on https://blog.amp.dev/2019/08/28/analytics-for-your-amp-stories/ but we are not getting any data except PageView Data as we have added this code {"storyPageVisible":{"on":"story-page-visible","request":"pageview"}.
Can you once check the code where the implementation is according to the latest update? and also please suggest to us that do we need to change anything else while creating the Dashboard other than the guidelines.
@jeffjose can you take a look at their configuration and see if they're missing something? They are using the default configuration specified in the blog post using Global Site Tag, which I'm not familiar with. Their config:
<amp-analytics type="googleanalytics" data-credentials="include">
<script type="application/json">
{
"vars": {
"account": "UA-100756269-3",
"config": {
"UA-100756269-3": {
"groups": "default"
}
}
},
"triggers": {
"storyPageVisible": {
"on": "story-page-visible",
"request":"pageview"
},
"storyProgress": {
"on": "story-page-visible",
"request": "event",
"vars": {
"event_name": "custom",
"event_action": "story_progress",
"event_category": "${title}",
"event_label": "${storyPageId}",
"send_to":["UA-100756269-3"]
}
},
"storyEnd": {
"on":"story-last-page-visible",
"request": "event",
"vars": {
"event_name": "custom",
"event_action": "story_complete",
"event_category": "${title}",
"send_to":["UA-100756269-3"]
}
}
}
}
</script>
</amp-analytics>
I would say the "requests" property with the "endpoint" is missing, but since the blog post doesn't specify if it's needed with Global Site Tag, I'm not entirely sure.
Hi @Enriqe @jeffjose Is there any update on the above concern.
Hi @abhiz10, have you tried adding enabled: true to your config. The storyProgress and storyEnd are disabled by default.
Hi, @zhouyx Thanks for the solution, sorry for the late reply ... it's working fine now.
Hi, @zhouyx I need help with this Add your amp-analytics configuration to the story. We will be using the ${storyInteractiveId} and ${storyInteractiveResponse} to gather additional information on the responses. https://amp.dev/documentation/examples/components/amp-story-interactive-quiz/?format=stories How to add in my existing working GA code. { "vars":{ "account":""UA-XXXXXXXXX-3"", "config":{ "UA-XXXXXXXXX-3":{ "groups":"default" } } }, "triggers":{ "storyPageVisible":{ "on":"story-page-visible", "request":"pageview", "extraUrlParams":{ "cd1":"AMP", "cd2":"${ampdocHost}" } }, "storyProgress":{ "on":"story-page-visible", "request":"event", "enabled":"true", "vars":{ "event_name":"custom", "event_action":"story_progress", "event_category":"${title}", "event_label":"${storyPageId}", "send_to":["UA-XXXXXXXXX-3"] } }, "storyEnd":{ "on":"story-last-page-visible", "request":"event", "enabled":"true", "vars":{ "event_name":"custom", "event_action":"story_complete", "event_category":"${title}", "send_to":["UA-XXXXXXXXX-3"] } } } }
@mszylkowski have we added analytics to the amp-story-interactive-* components?
@Enriqe Yes that has been integrated since the beginning, check https://github.com/ampproject/amphtml/blob/1ff2dfb860b8d9752cae6292d51b799c4586caa9/extensions/amp-story-interactive/0.1/amp-story-interactive-abstract.js#L517-L536
Have we also documented those? Would you mind linking them for @abhiz10 please?
https://amp.dev/documentation/components/amp-story-interactive/#analytics
Thank you so much @mszylkowski @Enriqe