From 6f999488e7dc6a6b91fc3e9d74488eb515b7df40 Mon Sep 17 00:00:00 2001 From: Rudy Galfi Date: Mon, 5 Feb 2018 14:30:13 -0800 Subject: [PATCH] Adding amp-story-analytics (#13276) --- extensions/amp-story/amp-story-analytics.md | 68 +++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 extensions/amp-story/amp-story-analytics.md diff --git a/extensions/amp-story/amp-story-analytics.md b/extensions/amp-story/amp-story-analytics.md new file mode 100644 index 000000000000..aec684123d13 --- /dev/null +++ b/extensions/amp-story/amp-story-analytics.md @@ -0,0 +1,68 @@ + + +# AMP Story and Analytics + +## Story triggers + +`amp-story` issues events for changes of state. These events can be reported through the analytics configuration by using triggers. + +See [amp-analytics.md](../amp-analytics/amp-analytics.md) for details on *amp-analytics* configuration. + +### Visible trigger (`"on": "story-page-visible"`) + +The `story-page-visible` event is issued when a story page becomes visible. + +```javascript +"triggers": { + "storyPageVisible": { + "on": "story-page-visible", + "request": "event" + } +} +``` + +Because of the user experience of AMP story enables a user to traverse several "pages" without loading new HTML pages each time, one interesting consideration involving the `story-page-visible` event is how to record pageview events. One approach would be to count each `story-page-visible` event as a typical pageview (i.e. as if a user were visiting a new HTML page); another approach is to capture `story-page-visible` events specially as their own type of event. + +Using `amp-analytics` you can re-assign the `story-page-visible` event to behave like a pageview event, which is a common vendor-specified event type: + +```javascript +"triggers": { + "storyPageVisible": { + "on": "story-page-visible", + "request": "pageview" + } +} +``` + +Consult your vendor's documentation for more specific details on how to set this up. + + +## Story variables + +AMP story contributes the following URL substitutions: + +### STORY_PAGE_ID + +The unique ID for an AMP story page, as provided by the `id` attribute of the current `amp-story-page`. + +### STORY_PAGE_INDEX + +A zero-based index value for an AMP story page determined by its ordering within `amp-story`. + +### Additional Vars + +Description of additional variables can be found in the [analytics-vars.md](../amp-analytics/analytics-vars.md) file.