Client tracking unification from an AMP page to non AMP page with amp_id

Hello,

In order to get a unified snowplow “client” tracking between AMP pages and non AMP pages, and despite having reading the official documentation and other related posts, we are still misunderstanding the method to reach the objective.

Our first goal is to apply this feature so that we can track from an AMP page (AMP tracker) to a non AMP page (JS-tracker page).
Here’s we have done so far :

  • we have enabled the linker with minimal settings.
    "linkers": { "enabled": true },
  • we have noticed that when navigating from an AMP page to a non AMP page, the querystring contains the amp_id as expected .
  • in the snowplow debugger for chrome, on an AMP page, we have taken the ampClientId and compared it with the decoded base-64 amp_id after navigating to a non AMP page —> it matches.

As it is written in the documentation of the google AMP tracker (1.0.1) in the section AMP page to JS-tracker page about the amp_id parameter, we should map the decoded amp_id to the domain userid (or any other user value) from the Javascript tracker:

The structure of this param is explained in the AMP documentation – models can extract the base64-encoded AMP Client ID, decode it, and map it to the domain userid (or any other user value) from the Javascript tracker.

OR in other words, as said in another snowplow page:

If a domain_userid is found by the AMP tracker, it is not guaranteed to be attached to every event. Therefore, a good strategy for modeling user identification on both sides is to create a mapping table of domain_userid to amp-id, and join this to the rest of the data to attribute users.

This is precisely where we are stucked.
We would like to know the following things :

  • how to create this mapping table of domain_userid to amp-id and how to join the rest of the data to attribute users?
  • once we get the amp_id in the query string, how could we send this amp_id in the js tracker, so that we can identify this same user in snowplow?

Thanks
patrick

Hi Patrick,

Good to hear you’ve started using the AMP tracker. :slight_smile:

  • how to create this mapping table of domain_userid to amp-id and how to join the rest of the data to attribute users?

This is something you would do at the data modeling stage - typically in the warehouse, after you’ve collected the data.

Typically you would have a SQL query create a table which maps domain_userid to amp_id. Then you would join this table to your other data (eg. a page views table) to produce the reports you need.

  • once we get the amp_id in the query string, how could we send this amp_id in the js tracker, so that we can identify this same user in snowplow?

There currently is no method to extract the value in the javascript tracker automatically. However the encoded value is in the querystring and so will be in the page_url, and page_urlquery values in the events table.

There are two ways to approach parsing this value and using it:

  1. In SQL, you can regex extract the amp_id value from the linker parameter from the querystring (it looks like this ?linker=1*1c1wx43*amp_id*amp-a1b23cDEfGhIjkl4mnoPqr), and also extract the amp_id value. You need to extract the value which comes after amp_id*.

  2. You could add some Javascript to your websit to parse this value from the query string similarly, and either send it as a custom event, or attach it as a custom context to existing events.

I hope this helps, it’s not incredibly convenient - ultimately the awkwardness of AMP’s mechanics have made it difficult to enable a seamless transition into our existing tooling, so there is more work to be done on our side. :slight_smile:

Hi,

We choosed to parse the query string on the front side and attach it as a custom context.
It works correctly.

Thanks for your reply.
Patrick

Hi @Patrick,

Have you checked your non-domain amp page to Js tracker link decorations since the update?
From My understanding, the changes pushed to snowplow amp v1-0-2, the destination url should be decorated with the new sp_amp_linker query parameter. Are you seeing that in the url?

Thanks a lot
Yazan