Using Google Analytics with AMP
Implementation of Google Analytics into AMP. The plugin can be implemented by providing a googleanalytics
object in the player config:
var config = { plugins: { googleanalytics: { resources: [ {src: "//www.google-analytics.com/analytics.js", type: "text/javascript", async: true}, {src: "#{paths.plugins}googleanalytics/Googleanalytics.js", type: "text/javascript", async: true} ], trackingId: "UA-82788715-3", nonInteraction: false, disablePageView: false, events: { video: [{ type: "started", data: { eventCategory: "video", eventAction: "videoStart", customDimension : { metric1: "viewDuration", dimension1: "#{media.title}", metric2: "#{media.duration}" } } }, { type: "ended", data: { eventCategory: "video", eventAction: "videoEnded", customDimension : { metric1: "viewDuration", dimension1: "#{media.title}", metric2: "#{media.duration}" } } }], ads: [{ type: "started", data: { eventCategory: "ad", eventAction: "adStarted" } }, { type: "ended", data: { eventCategory: "ad", eventAction: "adsEnded" } }] } } } }; akamai.amp.AMP.create("amp", config);