Note:
Google Analytics 4 cannot be configured with analytics.js. This can be done using `gtag.js`
[Setup Google Analytics gtag.js with AMP](https://developer.akamai.com/tools/AdaptiveMediaPlayer/docs/web/amp-web-google-analytics/tutorial-3-gtag.html)
Google Analytics 4 cannot be configured with analytics.js. This can be done using `gtag.js`
[Setup Google Analytics gtag.js with AMP](https://developer.akamai.com/tools/AdaptiveMediaPlayer/docs/web/amp-web-google-analytics/tutorial-3-gtag.html)
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: "adstarted",
data: {
eventCategory: "ad",
eventAction: "adStarted"
}
}, {
type: "adended",
data: {
eventCategory: "ad",
eventAction: "adsEnded"
}
}]
}
}
}
};
akamai.amp.AMP.create("amp", config);