How to add Google Analytics to AMP pages on WordPress

Last Updated on August 24, 2017 by Chris Christoff

If you have installed one of the AMP plugins for WordPress, you have probably discovered that by default the Google Analytics code is stripped out from Accelerated Mobile Pages on WordPress.

Furthermore, by manually adding the default Google Analytics tracking code to AMP pages, you will encounter different issues like double tracking of certain sessions and the /amp suffix being added to the tracked pages.

Here’s where Google Analytics Dashboard for WP comes in useful. With the switch of a button, the plugin will add full support for Google Analytics on your WordPress AMP webpages.

About the AMP Project

The AMP Project is an open-source initiative aiming to take the user browsing experience to a next level. The project enables the creation of webpages that are consistently fast across devices.

To provide a better browsing experience, AMP pages are built using three core components: AMP HTML, AMP JS and AMP Cache. These core components are designed to ensure reliable performance, fast rendering and caching.

Support for AMP pages is widely provided by leading CMS providers like WordPress and AMP is adopted by the search engines which are integrating AMP listings into their search results.

AMP provides benefits for both parties: users and publishers. Users can enjoy a much better browsing experience while publishers can benefit of an increased user engagement.

How to add Google Analytics to AMP pages on WordPress

If you don’t add Google Analytics tracking to your AMP pages, you will be missing key analytics data about your AMP driven traffic. Since you won’t be tracking hits for AMP pages, you’ll miss meaningful insights about your mobile users.

Adding the tracking code manually will have its own downside. While the default AMP analytics tracking code will enable tracking for AMP pages, there are a few issues that won’t be handled automatically. One of the common issues is having the same page reported with two different paths (the original path and one with an /amp suffix).

To add Google Analytics to AMP pages on WordPress, you will need to install Google Analytics Dashboard for WP (GADWP). It’s a full featured plugin which will provide advanced Google Analytics tracking capabilities to your website. Furthermore the plugin will display analytics reports on your dashboard and webpages.

After installing and properly configuring GADWP, to enable AMP tracking support, switch on the enable tracking for Accelerated Mobile Pages (AMP) option from Google Analytics -> Tracking Code -> Integration screen.

How to add Google Analytics to AMP webpages on WordPress

Once enabled, it will provide the following AMP analytics features:

  • Removes the /amp suffix from tracked page URLs.
  • Scrolling depth tracking.
  • Custom dimensions tracking.
  • User sampling rate control.
  • Form submit tracking.
  • File downloads tracking.
  • Affiliate links tracking.
  • Hashmarks, outbound links, telephones, and e-mails tracking.
  • Custom event categories, actions, and labels using annotated HTML elements.

How to display AMP stats on Google Analytics reports

By default, hits sent from analytics.js are reported as “web” and hits sent from AMP are reported as “amp” using the Data Source dimension.

Using the data source dimension, you can configure a dedicated View with the help of filters. This View will only include your AMP analytics data and filter out everything else. Another option is to create a new segment for the AMP users and use it to display both Web and AMP data under the same reports.

To create a new segment:

  • Go to
  • Click on Admin.
  • Select the targeted Account, Property and View.
  • Under Personal Tools and Assets section, select Segments.
  • Click on New Segment.
  • Give a meaningful name to your segment, like AMP Users.
  • Select Conditions.
  • Choose Users as Filter, Data Source instead of Ad Content, and exactly matches instead of contains.
  • Enter amp in the input field.
  • Click Save.

AMP Data Source segment in Google Analytics

Now you can use the newly created AMP segment on your reports by following these steps:

  • Select the desired Account, Property and View.
  • Choose a report like All Pages from Behavior section.
  • Add the newly created AMP Users segment at the top of the screen by clicking the + sign.

Google Analytics AMP Report

The final report will show you stats segmented by AMP users, as above. In addition, you could use another segment for Non-AMP Users to display more detailed insights.

To setup a Non-AMP Users segment you need to follow the same steps described above and switch exactly matches to does not exactly match.

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.