Unifying clientId on AMP & Non-AMP Pages

Estimated Reading Time: 5 minutes

Accelerated Mobile Pages (AMP) are becoming increasingly popular across the Internet, as companies and websites try to deliver a faster, better user experience for mobile devices.

Why are AMP becoming so popular? I’m glad you ask!

By using AMP pages,  search results can appear higher on the page in Google’s carousel. This can help increase visibility and clickthrough rates.

But up until now, a major issue with tracking AMP pages using Google Analytics has been related to identifying users. Because cached AMP pages showing up in Google’s search results are cached on a separate domain from your site, there was no way to pass clientId (a randomly generated alphanumeric that is used by GA identifies to identify unique users) from the cached AMP page in Google’s search results to your website.

See the diagram below for a better idea of the clientId issue:

clientId is not passed from our cached AMP page in Google’s search result to our non-AMP pages, causing this user to appear as two users instead of one.

If you are tracking your AMP pages in the same Google Analytics property as your main website, this would have essentially counted that user twice, once on the Google-cached AMP page and once on your website.

Obviously, this is an issue, because I’m one user in reality, but showing up twice in Google Analytics because of this clientId limitation.

But I have exciting news! The AMP team, along with Google, has announced a clientId API where AMP and non-AMP pages can tap into to unify clientId. This means no more double-counting users moving from a cached AMP page to a non-AMP page. This is HUGE for publishers!

I’ve had a few of our publishing clients complain for almost a year now about this double-counting issue with no real solution in sight. Now, this update alleviates these concerns by tapping into an AMP clientId API to unify clientId’s across scenarios.

Implementation

It’s actually a very easy two-step process to set this up. First, you’ll need to add one line of HTML to all of your AMP pages:

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

The second step will be to update your Google Analytics code on non-AMP pages. If you are not using Google Tag Manager, you’ll need to update the ‘set’ command in your Google Analytics tracking code, like so:

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

Notice the ‘useAmpClientId’ variable is added and set to ‘true’.

If you are using Google Tag Manager to add Google Analytics to your site, it’s an even easier update. In your Google Analytics tag(s), you’ll need to go to More Settings > Fields to Set and set the Field Name to ‘useAmpClientId’ with a value of ‘true’ (no single quotes):

Testing

To make sure this process works as advertised, you’ll want to make both updates as outlined above and start testing. The easiest way to do this is to use the Chrome browser and it’s mobile emulator tool in the Developer’s Console. To do this, press Option + Command + J (for Mac) or Cmd + Option + J (for you savage PC users) and click on the Mobile Emulator icon at the top left (highlighted in red in the screenshot below) and choose a mobile device model.

Cached AMP page’s pageview request – notice clientId starts with “amp-”

Now, you’ll need to find a cached AMP version of your site in Google’s search result and open that. You will then be viewing the AMP version of your page in Google’s search result.
To check your clientId, click over to the Network tab in your Developer Console and find the “collect?v=1&ds=AMP…..” request (see above screenshot). This is the Google Analytics request that is sending the AMP pageview (ds = data source). Scroll down in the Headers section to find the “cid” parameter which is your cliendId. You can see this one starts with “amp-”. This is your AMP clientId.

Now, on your cached AMP page, you’ll need to find a link that will take you to your regular, non-AMP website. Click on that link and then find the “collect?v=1” request again. This time it won’t include ds=AMP because it’s not an AMP page. You’ll want to look for the request with “t=pageview”.

It’s easier on your non-AMP page if you use the GA Debugger Chrome extension and find the pageview request that way and then check your clientId. See the below screenshot of GA Debugger and the pageview request.

Non-AMP page’s Pageview request – notice clientId matches AMP pages clientId from previous screenshot

If your setup is working properly, the clientId should match what it was on the cached AMP page. This means your clientId has remained the same and you’ll be identified as one user. The clientId won’t always start with “amp-”. If you’ve been to the regular, non-AMP website before and been assigned a Google Analytics clientId (something like 12345699.12345676), then when you visit a cached AMP page in Google search, your clientId will stay as 12345699.12345676.

So, the testing process is a bit technical, but this way, you can ensure you are keeping the same clientId as you go from cached AMP page to regular, non-AMP page and back to cached AMP page. Pretty awesome!

For more information on how the integration works and how clientId is treated in different scenarios, visit Google’s Client IDs in AMP pages Developer’s page.

Author

  • Andy Gibson

    Andy is the Head of Vertical - News & Media at InfoTrust. He enjoys Dayton Flyers basketball, his pitbull rescue, Millie, and trying to figure out how to cook for himself. He's an expert with Google Analytics and Google Tag Manager, if you're into that kind of thing.

Facebook
Twitter
LinkedIn
Email
Originally Published: September 19, 2017

Subscribe To Our Newsletter

October 18, 2023
Originally published on September 19, 2017

Other Articles You Will Enjoy

Advanced Analysis Techniques in Google Analytics 4: How to Use AI-Powered Insights and Predictive Analytics for Effective Marketing

Advanced Analysis Techniques in Google Analytics 4: How to Use AI-Powered Insights and Predictive Analytics for Effective Marketing

AI-powered insights and predictive analytics are revolutionary tools reshaping the modern marketing landscape. These advanced analytics techniques, particularly prominent in Google Analytics 4 (GA4),…

8-minute read
How to Integrate Google Analytics 4 with BigQuery for Enhanced Data Analysis and Reporting

How to Integrate Google Analytics 4 with BigQuery for Enhanced Data Analysis and Reporting

Has your business found that its reporting needs require advanced analysis of your analytics data beyond what is practical in the Google Analytics 4…

4-minute read
Is It Time to Upgrade? 4 Signs Your Organization Needs Google Analytics 4 360

Is It Time to Upgrade? 4 Signs Your Organization Needs Google Analytics 4 360

As VP of Partnerships at InfoTrust, I’ve had the opportunity to talk with hundreds of decision-makers about their interest in upgrading to Google Analytics…

4-minute read
Leveraging Attribution Models in Google Analytics 4 to Improve Your Marketing Strategy: Tips and Best Practices

Leveraging Attribution Models in Google Analytics 4 to Improve Your Marketing Strategy: Tips and Best Practices

In the dynamic landscape of digital marketing, understanding the customer journey is crucial for optimizing strategies and maximizing ROI. Google Analytics 4 (GA4) introduces…

5-minute read
Leveraging Custom Dimensions and Metrics in Google Analytics 4 for Content Performance Measurement: Best Practices and Real-World Examples

Leveraging Custom Dimensions and Metrics in Google Analytics 4 for Content Performance Measurement: Best Practices and Real-World Examples

In today’s digital landscape where content reigns supreme, understanding how your audience interacts with your content is paramount for success. For news and media…

5-minute read
Google Analytics 4 Implementation Checklist: Ensure You’re Tracking Everything You Need

Google Analytics 4 Implementation Checklist: Ensure You’re Tracking Everything You Need

In the dynamic landscape of digital marketing, data is supreme. Understanding user behavior, preferences, and interactions on your website is crucial for making informed…

4-minute read
Tracking User Behavior with Events in Google Analytics 4: Examples and Use Cases

Tracking User Behavior with Events in Google Analytics 4: Examples and Use Cases

So you’ve created your Google Analytics 4 (GA4) properties, created your data stream(s), and followed all the necessary steps to configure your property. Now…

5-minute read
How Does BigQuery Data Import for Google Analytics 4 Differ from Universal Analytics?

How Does BigQuery Data Import for Google Analytics 4 Differ from Universal Analytics?

All Google Analytics 4 (GA4) property owners can now enable ‌data export to BigQuery and start to utilize the raw event data collected on…

2-minute read
App Install Attribution in Google Analytics 4: What You Need to Know

App Install Attribution in Google Analytics 4: What You Need to Know

App install attribution in Google Analytics for Firebase (GA4) is a feature that helps you understand how users discover and install your app. It…

6-minute read

Get Your Assessment

Thank you! We will be in touch with your results soon.
{{ field.placeholder }}
{{ option.name }}

Talk To Us

Talk To Us

Receive Book Updates

Fill out this form to receive email announcements about Crawl, Walk, Run: Advancing Analytics Maturity with Google Marketing Platform. This includes pre-sale dates, official publishing dates, and more.

Search InfoTrust

Leave Us A Review

Leave a review and let us know how we’re doing. Only actual clients, please.