Skip to content

[Master feature] AMP Linker #16737

@calebcordry

Description

@calebcordry

We intend to implement a link decoration based solution for AMP pages to sync IDs across domains.

Design Goals

  • Join user sessions when user navigates from AMP cache to publisher origin.
  • Enable analytics vendors to provide a default configuration. This creates a simple mechanism by which publishers can turn this feature on/off.
  • Easy upgrade path to a 3rd party cookie based solution on supported browsers.

There are three major pieces to this implementation

  1. Implement CREATE_LINKER_PARAM macro.
  2. Implement LINKER_PARAM macro.
  3. Implement linkers config in amp-analytics

CREATE_LINKER_PARAM macro

The purpose of this macro will be to generate a query parameter in the following format:
<paramName>=<version>~<checksum>~<key1>~<value1>~<key2>~<value2>...

  • version is a base64url number
  • fingerprint = UA + timezone + language
  • checksum = base64url(CRC32(fingerprint + timestampRoundedInMin + kv pairs))
  • All values are base64url encoded
  • The Delimiter “~” was chosen because “.-_” are all used by base64url.
  • Each vendor will have one URL param for all linkers they have.

The proposed API:

CREATE_LINKER_PARAM(vendorId, {
  key1: value1,
  key2: value2,
  ...
})

Example:

linkerParams: {
  _linker: CREATE_LINKER_PARAM(coolAnalytics, {
    cid: CLIENT_ID(_foo),
    qid: QUERY_PARAM(bar),
  })
}

LINKER_PARAM macro

This will read and decode the generated linker query parameter.
The proposed API:

LINKER_PARAM(vendorId, version, parameterName, allowedIntervalInMin)

Example:

writeCookies: {
  _cookieName: "LINKER_PARAM(coolAnalytics, 2, _linker, 2)",
}

// returns the map of values passed into `CREATE_LINKER_PARAM`

linkers amp-analytics config

Proposed config spec:

linkers: {
  <name>: {
    linkerParams: <Object>, // Key: param name, Value: string containing macros
    sourceDomains: <Array<string>>, // Optional, default to Cache domain
    destinationDomains: <Array<string>>, // Optional, default to canonical & source domains
  },
  ...
}

Example:

linkers: {
  linkerA: {
    linkerParams: {
     _linker: CREATE_LINKER_PARAM('coolAnalytics', {
      cid: CLIENT_ID(_foo),
      qid: QUERY_PARAM(bar)
    }),
    sourceDomains: ["cdn.ampproject.org"],
    destinationDomains: ["pub.com"],
  }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions