Track video analytics from an AMP implementation

Learn how to track video analytics and include the data in your Google Analytics data.

After embedding adding the amp-jwplayer component to a Google AMP page, you can track the user interaction with your video or audio content.


On your AMP page, add an amp-analytics component after the amp-jwplayer component.

<amp-analytics type="googleanalytics" data-credentials="include">
    <script type="application/json">
        {
            "vars": {
                "account": "{google_analytics_id}"
             },
             "triggers": {
                 "eventTriggerName": {
                     "on": "video-play",
                     "request": "event",
                     "selector": "#myVideo",
                     "vars": {
                         "eventCategory": "video-events",
                         "eventAction": "video-play"
                     }
                 }
             }
         }
    </script>
</amp-analytics>
PropertyDescription
triggers* objectConfiguration object that contains child objects that describe event triggers.

Each child object represents a single event trigger that describes when analytics requests should be sent.

To identify an event trigger in your analytics, name each event trigger object. The event trigger object name can be any string comprised of alphanumeric characters (a-zA-Z0-9).

See: triggers.{eventTriggerName}
vars* objectObject containing basic amp-analytics component variables

See: vars


triggers.{eventTriggerName}

PropertyDescription
on* stringEvent for which to listen

Supported events:
   • video-ad-end
   • video-ad-start
   • video-ended
   • video-pause
   • video-percentage-played
   • video-play
   • video-session
request* stringName of the request to send

This should always be set to event.
selector* stringValid CSS selector used to select the amp-jwplayer component to track
vars* stringObject containing key-value pairs specific to this trigger

See: triggers.{eventTriggerName}.vars

triggers.{eventTriggerName}.vars

PropertyDescription
eventAction* stringName for the given event

To learn more about the eventAction property, read Event Management.
eventCategory* stringCategory for the given event

To learn more about the eventCategory property, read Event Management.

To learn more about the triggers object, read Triggers.


vars

PropertyDescription
account* string
                                        
Identifier for the Google Analytics account to which video analytics are sent

To learn more about the vars object, read Vars.



Did this page help you?