AMP Tracking Recommendation

Subscribe to our monthly newsletter to get the latest updates in your inbox

As the conversation picks up around Accelerated Mobile Pages (AMP), so do our client inquiries about how to effectively track them in Google Analytics. We hope this post can be a one-stop shop for best practices. The standards for tracking have been consistently updated and revised, as evidenced by the post which Google recently published on how they’ve enhanced “ Support for AMP on Cache.” The hallmark of their recent release is the AMP Client ID API. This new rollout will enable pages which are hosted on Google’s platforms (AMP pages) to share information that's hosted on your owned domains. The standing recommendation prior to this API release was to collect AMP traffic in a separate Google Analytics property, due to the fact that AMP page viewers would be assigned a separate client ID in Google Analytics. This, as you can imagine, would surely skew the numbers, which you’re accustomed to reporting on for new and returning users. Fortunately, the introduction of the new API could change our standing recommendation! Specifically, the API will allow for understanding if a user who's visited your website has also visited an AMP page owned by you, but displayed by Google. If this is the case, we’re now able to view this in Analytics as a collection of behavior under a single client ID (user). This upgrade is not automatic and does need to be proactively opted into. By opting in, you’re also agreeing to Google’s new AMP Client ID API policy. You’ll need to make two configuration updates. One to your AMP Pages and one to your tracking method, be it analytics.js (hardcoded analytics) or Google Tag Manager. If you’re still using the ga.js library you will need to upgrade prior to taking advantage of the new API. These updates make it so possible to track AMP pages in the same properties as we’re sending our “normal” traffic. Don’t forget…you’re still able to segment out this traffic with the handy, built-in dimension of: “Data Source”.     For additional dimensionality, also consider adding a Custom Dimension version of “Data Source.” This will require a bit more work, but I’ve laid out the instructions below. Since Data Source is not a dimension you can build a View Filter with, this would be required to separate out AMP traffic on a View level.  

Custom Dimension Installation Instructions:

In your AMP GTM Container, navigate to the Pageview tag. Set up according to the image below:    

AMP API Installation Instructions

AMP Page Code Update: Include the following code in the <head> of your AMP page:
<meta name="amp-google-client-id-api" content="googleanalytics">
  Google Tag Manager Web Container Update: In your settings variable or in your primary Google Tag Manager container—not your AMP container—Pageview Tag(s), apply the following field to set: Field Name: 'useAmpClientId', Value: 'true'       analytics.js Tracking Library Update (If you’re not using GTM): Include the following in your Analytics tracking code:
ga('create', 'UA-XXXXX-Y', 'auto', {'useAmpClientId': true});
  Contact us with questions!