Accelerated Mobile Pages (AMP) is an open source page format for the mobile web that makes it possible for your pages to render almost instantly on mobile devices. AMP pages are similar to HTML pages and load in any browser. However, you cannot use analytics.js on Accelerated Mobile Pages, so a different Analytics tag is provided specifically for AMP.
Analytics data collection is implemented as a layer on top of the Measurement Protocol. User identifiers are randomly generated and stored either in localStorage or cookies. The user identifier is reset when the user clears cookies and local storage. The AMP tag supports IP truncation as described in IP masking in Analytics. Data from AMP documents is always IP masked.
AMP Analytics supports the Analytics opt-out. If the opt-out is installed, Analytics data collection is disabled.
Accelerated Mobile Pages allow users to engage with content from a single publisher on multiple sites during the same session. Learn more about session-based metrics collected from Accelerated Mobile Pages.
Requirements
To use Analytics on AMP pages, you must:
- Disclose how Analytics collects and uses data, and offer users the opportunity to opt-out of Analytics. You can do this by linking to the Google privacy and terms, which includes a link to the Analytics opt-out page.
- Use the AMP Analytics tag on your mobile pages. Refer to the AMP Analytics spec on Google Developers.
Capabilities and limitations
AMP Analytics allows you to collect the following data:
- Page data: Domain, path, page title
- User data: client ID, timezone
- Browsing data: referrer, unique page view ID
- Browser data: screen height, screen width, user agent
- Interaction data: page height and page width
- Event data
Additional considerations
The Google AMP Client ID API was recently launched to improve user analysis across pages served on your domain and AMP pages served within Google viewers. In addition to serving super-fast AMP content on your own domain, AMP content will also be served directly via Google viewers. However, if you don’t use the Google AMP Client ID API, having pages served in at least two contexts—within Google viewers and on your own site—will result in multiple identities for a single user that engages with your content across these two (or more) touch points.
Cache vs. non-cache analysis
If you’d like a deeper understanding of how users interact with AMP pages on cache vs. your own domain, then you can use the following instructions to send that data to Analytics via a custom dimension:
- Add a new custom dimension via the Analytics interface. Make it a hit level dimension and note the index number.
- Add the following config to the Analytics tag on your AMP pages:
extraUrlParams: { 'cd<index 1="" from="" step="">': '${ampdocHost}' } EX: So if the index is 5 then the config will be: extraUrlParams: { 'cd5': '${ampdocHost}' }
- Relaunch your AMP pages and you'll see the hostname flowing into the new custom dimension.
- After you relaunch your AMP pages, you can set up a Custom Report with the new custom dimension, or access the custom dimension in any of your normal reporting processes.