1. Home
  2. How To
  3. Setting up Session Stitching and Google AMP Client ID API

Setting up Session Stitching and Google AMP Client ID API

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.


1. AMP

In AMP options Panel, select Google Analytics as the Analytics Type.

If you are using GTM then enable the GTM support and add ‘googleanalytics’ as Analytics Type from AMP options Panel.


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});


Session Stitching, the Advanced Class

The above outline to address session stitching should allow you to capture all of your users, but it does leave some issues. What it’s doing is taking data from two different sources and tie them together with a Client ID. At this point, you’ll be abe to see what’s coming through AMP pages vs. regular pages. There are still some shortcomings:

  • You can’t see the difference between your own hosted AMP pages vs. Google CDN hosted pages.
  • If you segment to determine transaction sources, the AMP pages will show as a web data source with zero sessions and some transactions.

The following steps will help address those issue.

1. The first additional step is to make sure that ‘’ is added into the Referral Exclusion List under the Property Settings in the Admin section of the Google Analytics account. This should remove a majority of self-referrals from the CDN: This does not remove the records in GA. It removes the referral (source/medium) over-ride from the user moving from CDN to site on 2nd click. Therefore, if the traffic hits the CDN via google/cpc or google/organic it remains as that for the cross-Data Source navigation … rather than being over-ridden by the Referral from the CDN.


This referral exclusion will help e-commerce (and other) sites maintain tracking of a user session from initial entry on an AMP page in the CDN all the way through to checkout.

2. Google also recommends that you add all subdomains of to your referral exclusion list as well. This step only applies if you’ve got subdomains on your site (or that are being used as PPC landing pages) that are coded in AMP. If the site does not have a need to specifically track/over-ride the referral currently when navigating between CDN and site then excluding ‘’ Referral covers any override from the CDN well enough. Google recommends excluding each subdomain but if you have a large number of subdomains in your setup, this may not be practical.

3. Create a Hit-level custom dimension called “AMPDOC_HOST” in the Google Analytics property: This enables you to segment traffic that started in CDN versus AMP hosted page.

4. Set the pageview in Google Tag Manager for the AMP Container to include the custom dimension set the “Dimension Value” to “AMPDOC_HOST”:


Note: “AMPDOC_HOST” does not need to be defined as a variable in the variable settings. The value can be set just like it is in the above screenshot.

5. You are then able to view pages served up in the CDN vs AMP pages in the content reports. To view landing pages served up by the CDN, filter by “cdn” by landing page:


6. Then, finally, exclude “cdn” and include “amp” in the filter to view AMP landing pages:


Final Notes on Session Stitching

Support for AMP by other analytics providers remains a work in progress for most. A Google spokesperson told me that the above outlined solution is available to third party analytics platforms, but that “the best place for info is still the Google Analytics solution, since the AMP team is still working on getting documentation up for other 3rd parties.”


Ask your Questions Directly!
If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!
Updated on April 5, 2018

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support


  1. Do I still need to pass through all these with your plugin?

    1. Hi Samy,

      Will you please explain what do you want so we will help you as soon as possible.


      Will you please elaborate more about your issue so that we will understand and help you.

  2. just show screenshot how to set useAmpClientId in GTM to Set up Google AMP Client ID API

    1. Hi Arul,

      Will you please elaborate more about your issue so that we will understand and help you.

  3. Thanks for the article, is there any way I can receive an update sent in an email every time you make a new update?

Leave a Comment