amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

AMP Story Analytics

Open AutadeJS opened this issue 7 years ago • 15 comments

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.

AutadeJS avatar Sep 09 '19 15:09 AutadeJS

/to @Enriqe

dreamofabear avatar Sep 10 '19 18:09 dreamofabear

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!

Enriqe avatar Sep 12 '19 21:09 Enriqe

Thank you so much

AutadeJS avatar Sep 16 '19 08:09 AutadeJS

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 ?

AutadeJS avatar Oct 01 '19 19:10 AutadeJS

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.

AutadeJS avatar Oct 04 '19 20:10 AutadeJS

@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.

Enriqe avatar Oct 07 '19 14:10 Enriqe

Hi @Enriqe @jeffjose Is there any update on the above concern.

abhiz10 avatar Nov 01 '19 05:11 abhiz10

Hi @abhiz10, have you tried adding enabled: true to your config. The storyProgress and storyEnd are disabled by default.

zhouyx avatar Nov 01 '19 22:11 zhouyx

Hi, @zhouyx Thanks for the solution, sorry for the late reply ... it's working fine now.

abhiz10 avatar Feb 22 '20 04:02 abhiz10

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"] } } } }

abhiz10 avatar Jan 30 '21 16:01 abhiz10

@mszylkowski have we added analytics to the amp-story-interactive-* components?

Enriqe avatar Feb 02 '21 20:02 Enriqe

@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

mszylkowski avatar Feb 02 '21 20:02 mszylkowski

Have we also documented those? Would you mind linking them for @abhiz10 please?

Enriqe avatar Feb 02 '21 21:02 Enriqe

https://amp.dev/documentation/components/amp-story-interactive/#analytics

mszylkowski avatar Feb 02 '21 21:02 mszylkowski

Thank you so much @mszylkowski @Enriqe

abhiz10 avatar Feb 03 '21 07:02 abhiz10