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.

Setup:

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.

2. NON-AMP

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

Resources:

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 ‘ampproject.org’ 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 ampproject.org 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 ‘ampproject.org’ 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.”

Resources

https://www.stonetemple.com/amp-tech-guide/

https://developers.google.com/analytics/devguides/collection/amp-analytics/client-id

https://support.google.com/analytics/answer/7486764

https://support.google.com/analytics/answer/6343176?hl=en&ref_topic=7378717

Share
Published by
Marqas

How to add Adobe Analytics in AMP

Follow these steps to add Adobe Analytics in AMP Step 1: Go to WordPress Admin Area -> AMP…

4 months ago

What is the CWV plugin all about

Core Web Vitals are the subset of Web Vitals that apply to all web pages,…

6 months ago

How to fix “Alternate page with proper canonical tag” Page Index issue in Google Search Console

The following reasons can be shown for non-indexing. Server error (5xx) Your server returned a 500-level…

8 months ago

Google Analytics ( GA4 ) integration in AMPforWP

We have added the Google Analytics 4 ( GA 4 ) integration in AMPforWP v1.0.80.…

1 year ago

How to add Marfell Analytics in AMP

In this article, I will show you how to add Dotmetrics Analytics to your AMP…

1 year ago

How to modify the H1-H6 size for mobile devices

In this option, we will show you how to modify the H1-H6 size for mobile…

1 year ago