Using Google's AMP Linker Tool with Tealium AMP Analytics

Employee Emeritus

Google decided with AMP HTML cache to copy the world's content to their own CDNs on, effectively keeping visitors on the domain even after clicking a Google search result. This creates an interesting analytics challenge when your visitors are viewing your content, but are still on And when that visitor clicks a link to eventually arrive on your original website, it becomes difficult to build an accurate visitor path report using traditional web analytics tools.

To help reduce the impact of this issue, Google AMP provides an AMP-linker tool that enables a visitor ID (generated by Google) on the AMP page to be passed along to the source domain so that you can connect the dots and see a more complete visitor path. This is referred to as the Google Client Id (CID). Google Analytics tags automatically picks up this value, so the following describes how to use this ID in a non-Google Analytics use case.

For a data collection use case where Tealium collects event data on your AMP pages (Tealium Collect AMP Analytics integration here), you can leverage the Google-generated CID value as your Tealium visitor ID for the rest of the visitor's engagement with your content.

The primary use case is specifically for tracking a visitor that navigates from an AMP page to a non-AMP page (as opposed to the other direction, which is rare).

This solution does not solve for all use cases (such as visitors moving between non-AMP to AMP pages by clicking back button and doing multiple Google searches). Google's legacy iframe tracking where the website hosts an HTML page that runs TMS inside of it may be better suited for more complex tracking scenarios.

Here are the steps to make this work.

1. Enable the AMP-linker by adding a configuration entry.

This is described here.

 <script type="application/json">
   // ..
   "linkers": {
    "enabled": true,
    "destinationDomains": [""],
    "linker1": {
     "ids": {
      "amp_cid": "CLIENT_ID(amp_cid)"

This lets the AMP HTML analytics vendor know that outgoing links to '' should be tagged with an amp_cid value. 

More Details: 

2. Add a snippet of code to Tealium iQ.

The next step is to read the value from the URL and use it as your visitor ID. In this case, we are only using this visitor ID for the case when we have a first-time visitor that is arriving from an AMP HTML page. Here is a simple JavaScript Code extension to accomplish this:

Sort this as the first JavaScript extension scoped to "All Tags - Before Load Rules"


// Look for amp_cid value in URL query string 
// and check to see if this is the first-time visit
if (b["qp.amp_cid"] !== undefined && b["tealium_session_number"] === "1" && b["tealium_session_event_number"] === "1") {

 // Set the utag_main_v_id cookie to persist
 utag.loader.SC("utag_main", {v_id: b["qp.amp_cid"] });
 b["cp.utag_main_v_id"] = b["tealium_visitor_id"] = b["qp.amp_cid"];

3. Use tealium_visitor_id in EventStream connectors (server-side), or iQ tags (client-side) as a standard visitor identifier for your vendors.

For more information on EventStream or client-side mapping, please visit here.

While cross-domain tracking has never been an exact science, modern web browsers continue to make this more difficult.  For the specific Google AMP use case, you can use Google and Tealium features together help. Using Google AMP-linker and Tealium JavaScript Code extensions provide for a more robust tracking implementation in the modern web.

3 Kudos