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>
Property Description
triggers* object
                                                  
Configuration 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* object Object containing basic amp-analytics component variables

See: vars



triggers.{eventTriggerName}

Property Description
on* string
                                        
Event for which to listen

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

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

See: triggers.{eventTriggerName}.vars


triggers.{eventTriggerName}.vars

Property Description
eventAction* string
                                        
Name for the given event

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

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


To learn more about the triggers object, read Triggers.


vars

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

To learn more about the vars object, read Vars.


Updated 8 months ago


Track video analytics from an AMP implementation


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

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.