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 Analytics Insights 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 Analytics Insights for WP. 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 Analytics Insights for WP, to enable AMP tracking support, switch on the enable tracking for Accelerated Mobile Pages (AMP) option from Analytics Insights -> Tracking Code -> Integration screen.
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 analytics.google.com.
- 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.
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.
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.