Maximize Your Referral Traffic with AMP Client ID API: How Much Can You Gain?

Boost Referral Traffic with AMP Client ID
Amit Founder & COO cisin.com
At the heart of our mission is a commitment to providing exceptional experiences through the development of high-quality technological solutions. Rigorous testing ensures the reliability of our solutions, guaranteeing consistent performance. We are genuinely thrilled to impart our expertise to you—right here, right now!!


Contact us anytime to know moreAmit A., Founder & COO CISIN

 

AMP content can be self-hosted on your own domain. However, AMP content being viewed directly within the search results of Google is what’s most popular.

Google search results AMP content is actually nothing but a copy of the AMP content self-hosted on your own domain which gets uploaded to Google AMP Cache automatically. It is Google AMP Cache that enables quick and robust hosting performance. What complicates the matter even further is the fact that the AMP cache version appearing in Google search lies within an <IFRAME>, or Google AMP Viewer; there’s a different URL associated with this version as well and the AMP Cache version could link to this URL directly.


Notable Issues with AMP and Google Analytics

Notable Issues with AMP and Google Analytics

 

Earlier users had quite a different method in which they arrived at a website via searching on Google. With the AMP project, the path that users have to follow now has changed significantly.

Superficially, the current process may seem easy and intuitive, however, the entire process that starts from search leads to AMP, and finally ends at website actually undergoes multiple 1st and 3rd party technologies and hosts. This changed process poses certain issues for Google Analytics, such as:

  1. As of now, there are several configuration options available in Universal Analytics that are not offered in AMP Google Analytics, including important options like cross-domain tracking and e-commerce.

  2. The storage mechanism for client ID for a website is different in AMP Google Analytics and Universal Analytics. The client ID is not shared between Google-hosted AMP and self-hosted content.

    Google-hosted AMP also doesn’t share the client ID with AMP cache-hosted content that’s not viewed in an <IFRAME> Google search viewer. What this means is that same user who is crossing from AMP while searching for something in Google and arriving at your website will not be recognized by Google Analytics out-of-the-box.

  3. Your user and session metrics face danger from the AMP Google Analytics data in a case where website data and AMP were to be combined in the same property.

    Tracking AMP to a separate property is also not a solution since this causes a gap in the Google Analytics data between the site and the search. In the AMP property, the search would get credit, and the same user would appear in site data as a referral from AMP Cache.


The Service of Google AMP Client ID API

The Service of Google AMP Client ID API

 

This is a service that helps with unique identification and analysis of user experience across both AMP and non-AMP versions of the content.

In this service, Google Analytics utilizes AMP Client ID to associate several website events to a particular user as they visit AMP pages through a Google AMP viewer.

So how does this service help with your data collection efforts? Unique identification of users across non-AMP and AMP pages means that when these uniquely identified users will return to your website, you’ll be able to assess and gauge their behavior with much greater accuracy through the session and user related metrics.


How to Setup Google AMP Client ID API?

How to Setup Google AMP Client ID API?

 

To start using the Google AMP Client ID API service, there are 2 mandatory requirements that you need to fulfill.

These requirements involve doing 2 code changes: one code change needs to be done on AMP pages and one code change needs to be done on non-AMP pages.

Few things that you should note as you implement this API service:

  1. Collect the data within the same GA property to ensure the utility of Client ID API.

  2. Sub-domain treatment will be the same for AMP and non-AMP pages. Referral exclusion should be used as per need.


1st Step:

In the first step, you need to opt-in for the service on the AMP pages.

In the <head> of your every AMP page, insert the above-mentioned code.

Keep in mind the below 3 guidelines when you use GA for your AMP pages:

  1. Adding amp-analytics element to the <body> section of HTML.

  2. Setting type attribute to googleanalytics.

  3. Defining the tracking configuration as per your requirement.

Remember to use AMP-compliant tags in Google Tag Manager, in case you are using the Tag Manager.


2nd Step:

In the second step, you need to opt in for the service on the non-AMP pages.

Below are mentioned different instructions for implementing GA, go with the ones that align the most with your needs.

The common objective in all these sets of instructions is that the useAMPclientID parameter should be set as true in the 1st call to the create function of Analytics. Also, you should verify the accurate functioning of the session stitching with the help of Setup Verification section.


Case 1: You are using gtag.js

In this case, you need to add the below code in your GA tracking code:

gtag('config', 'UA-XXXXX-Y', {'use_amp_client_id': true});


Case 2: You are using analytics.js

In this case, you need to add the below code in your GA tracking code:

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


Case 3: You are using a 3rd party tag manager

You need to add a useAmpClientId parameter and set it as true for the Analytics create-tracker code.

Check how to accomplish the same in your particular tag management system.


Case 4: You are using Google Tag Manager

If you already have one or more published containers, then follow the below steps. With GA Settings variable, you need to do just one change to upgrade all the related tags.

  1. Open the desired container in Google Tag Manager and then click on Variables.

  2. Open the GA Settings variable that needs to be edited. Click Variable Configuration card.

  3. Go to Fields to Set in More Settings.

  4. Click + ADD FIELD.

  5. Keep the Field Name as useAmpClientId. Keep the Value as true.

  6. Save the configuration changes that you’ve just made to the variable.

  7. If you have more variables in your container, then follow the above-mentioned steps for all the pertinent GA Settings variables.

  8. It’s now time for the container to be published.

In case you’re not using GA Settings variable, then you’ll need to change individual tags. Here’s how to do so:

  1. Open the desired container in Google Tag Manager. Click on Tags.

  2. Select the tag that needs to be edited and click on Tag configuration card.

  3. Go to Fields to Set in More Settings.

  4. Click + ADD FIELD.

  5. Keep the Field Name as useAmpClientId. Keep the Value as true.

  6. Save the configuration changes that you’ve just made to the tag.

  7. Follow the above-mentioned steps for all the pertinent GA tags.

  8. It’s now time for the container to be published.


3rd Step:

In the 3rd step, you’ll learn about employing referral exclusion as needed. AMP content is displayed to users by Google with the help of Google AMP Cache.

To prevent any session breakage by the cached AMP sub-domains delivered by Google, what you must do is add a referral exclusion with the domain: cdn.ampproject.org. It is also advised in the case where you are delivering AMP contents from several sub-domains, that you treat any given AMP sub-domain differently from the other one.

If this is the case for you, then you should mention the cached versions of the sub-domains that are currently being specified in referral exclusion for your site. That way you’ll be able to maintain certainly defined referral exclusions across non-AMP and AMP websites.

So for instance, if there’s already a referral exclusion for the sub-domain subdomain.example.com, go ahead and define a referral exclusion for subdomain-example-com.cdn.ampproject.org.

For your information, referral exclusions related to AMP can be specified in Analytics ADMIN together with the rest of your referral exclusions.


How to Verify that Your Setup of Google AMP Client ID API Service is Functioning Properly?

How to Verify that Your Setup of Google AMP Client ID API Service is Functioning Properly?

 

Following is a sequence of steps that you can follow to ensure the accurate working of the Google AMP Client ID API that you’ve just set up:

  1. Launch the incognito mode of Google Chrome browser. Now enable mobile emulator in Chrome DevTools.

  2. Perform such a search on Google.com that you get AMP page from your website as a result.

  3. Click on the search result that’s displaying the AMP page from your website. This page should be delivered through the Google AMP Cache and presented in the Google Search AMP viewer.

  4. Go to the Network tab in Chrome DevTools and filter for the string collect in order to learn the GA network request for the AMP pageview.

  5. Go with the network request that’s directed to www.google-analytics.com. There will be a Headers tab for this request on which you should scroll to Query String Parameters in order to discover the client ID.

    Make a note of the cid parameter. You know that your AMP pages have been accurately opted-in if you see that the client ID is beginning with the amp- prefix.

  1. Clear all the network requests by clicking on Clear.

  2. Now you need to confirm that you’ve also accurately opted-in for your non-AMP pages. For this verification, you have to ascertain that the cid parameter that you had noted earlier persists even when you visit a non-AMP page.

    On your AMP page, find and click on a link that leads to a non-AMP page delivered by your domain. Filter for the string collect again to discover the client ID. Choose a network request that leads to www.google-analytics.com.

    Now see that the cid parameter value that you had noted earlier is the same as the cid query-parameter value.

  1. In case the values of cid are not matching, execute the Analytics debugger and see whether the 1st call to ga("create" has the useAmpClientId: true parameter.

    Search for 'Running command: ga("create"' after opening Chrome DevTools.

Finally,

If you want to have a positive impact on your online search ranking and your traffic to generate more conversions then you must hire us as a digital marketing company.