Search
Clear search
Close search
Google apps
Main menu
true

Set up Google AMP Client ID API

Google’s AMP Client ID API is a service that allows you to uniquely identify and analyze a user’s experience across AMP and non-AMP content. It is available for anyone to use and is supported by optional tagging changes to your Google Analytics configuration.

About the AMP Client ID API

Google’s AMP Client ID API lets you uniquely identify users who engage with your content on AMP and non-AMP pages. If you opt-in, Google Analytics uses the AMP Client ID to determine that multiple site events belong to the same user when those users visit AMP pages via a Google viewer. Associating events and users provides features like user counts and session-based metrics.

Use the API to retrieve user IDs associated with AMP-page activity and consolidate those with your own representations of those same users on your non-AMP pages. The consolidated information provides a more accurate picture of user journeys and use of your service.

The API automatically sets the ID and expiration of the ID for each publisher. End users can opt out for individual publishers.

How the AMP Client ID API affects your data

As users who are uniquely identified across AMP and non-AMP pages return to your site, user- and session-related metrics more accurately reflect their behavior. For example, metrics like Session Duration, Bounce Rate, and Pages per Session will change positively to reflect a more accurate representation of behavior across AMP experiences.

In addition, as these users return to your AMP pages, their IDs will be reset. This will happen once for every user who comes to your AMP pages after opting into this solution. At that time they will be represented as a new user. Depending on the frequency with which users visit your site(s), this could cause a noticeable, temporary fluctuation in your New Users metric and related reporting.

Setup

By opting into usage of this service by way of encoding the prerequisite tagging changes shown below, you agree that you have read and acknowledge the Google AMP Client ID API Policy, and have implemented any requirements therein of this service in conjunction with any Google Analytics property with which it is used.

You opt into this service by making two code changes, one in your AMP page configuration file, and another in your Google Analytics javascript file.

Please also note that launching AMP pages is much the same as launching any other website, and that you should be mindful of subdomain usage and referral exclusion where needed and appropriate.

Opt in on your AMP pages

Include the following code in the <head> of all your AMP pages:

<meta name="amp-google-client-id-api" content="googleanalytics">

Opt in on your non-AMP pages

If you use Google Tag Manager

The following steps should be completed on your existing published tag container(s).

  1. Navigate to Tag Configuration > Fields to Set.
  2. Set useAmpClientId to true.
  3. Save the new tag configuration.
  4. Submit the tag.
  5. Publish the container.

If you use analytics.js

Include the following in your Analytics tracking code:

ga('create', 'UA-XXXXX-Y', 'auto', {'useAmpClientId': true});

Use referral exclusion

We advise that you add the single referral exclusion with the following domain: cdn.ampproject.org. This will exclude all cached AMP subdomains served by Google from breaking sessions incorrectly. However, it's also an approach that does not allow for different treatments across subdomains. If you have a reason to treat one AMP subdomain differently than another, then you should enter the cached versions of any existing subdomains used in referral exclusion for your website (for example: your-subdomain.cdn.ampproject.org) so you can maintain specific referral exclusions across AMP and non-AMP sites. You can enter these exclusions in Analytics ADMIN along with all of your other referral exclusions. Learn more

Was this article helpful?
How can we improve it?
Google Analytics training and support resources

Check out our comprehensive list to learn more about Analytics solutions.