Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Master feature] AMP Linker #16737

Closed
calebcordry opened this Issue Jul 14, 2018 · 12 comments

Comments

@calebcordry
Copy link
Member

calebcordry commented Jul 14, 2018

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"],
  }
}
@calebcordry

This comment has been minimized.

Copy link
Member Author

calebcordry commented Jul 14, 2018

@rudygalfi

This comment has been minimized.

Copy link
Contributor

rudygalfi commented Jul 16, 2018

cc @jeffjose Should we make this issue into a "Roadmap Highlight" (add label and re-title issue name to include "[Master feature]")?

@jeffjose jeffjose changed the title 🔗amp-linker I2I [Master feature] AMP ID link decoration Jul 16, 2018

@jeffjose jeffjose added this to Next Up in AMP HTML Project Roadmap via automation Jul 16, 2018

@jeffjose

This comment has been minimized.

Copy link
Collaborator

jeffjose commented Jul 16, 2018

Yup. Just changed it.

@shimonenator

This comment has been minimized.

Copy link

shimonenator commented Jul 24, 2018

Are there any plans to provide this functionality to the first-party iframes? By first party iframes I mean any iframe with the same second-level-ish domain, like for an amp page with origin www.example.com loading an iframe from amp-static.example.com.

CC @choumx, @mattludwig, @pbakaus

@lannka

This comment has been minimized.

Copy link
Collaborator

lannka commented Sep 9, 2018

@shimonenator do you want to automatically append IDs to the amp-iframe src? The current amp-analytics based approach would not work for it, because amp-iframe is loaded independent of amp-analytics. If amp-iframe is loaded before amp-analytics, there will not be any linker ID available yet.

The only viable option is to manually put IDs to each of your amp-iframe src. It's not doable yet, but can be easily done by allowing macro substitution in amp-iframe src.

We can open a separate I2I if that's something work for your use case.

@shimonenator

This comment has been minimized.

Copy link

shimonenator commented Sep 9, 2018

@lannka I think postmessage would do it

@tygavin

This comment has been minimized.

Copy link
Contributor

tygavin commented Sep 11, 2018

What about this use case?
(1) Search google.com and land on an google.com-hosted AMP html page
(2) The visitor does not do a second click to an article on publisher example.com page
(3) Click back to google.com and do another search
(4) Click a search result that lands you on publisher example.com page (non-AMP)

This results in 2 separate visits/visitors (as we have a page view in two separate domains)

My personal opinion is the easiest solution for allowing cross-domain visit tracking is simply "don't host AMP files on google.com domain."

Why not allow for a flag that allows an AMP page to indicate this "please-don't-cache-me" preference?

@lannka

This comment has been minimized.

Copy link
Collaborator

lannka commented Sep 11, 2018

@tygavin you're right, and that is a known limitation of this approach. We hope by AMPlifying more of your landing pages it could mitigate the issue.

My personal opinion is the easiest solution for allowing cross-domain visit tracking is simply "don't host AMP files on google.com domain."

Google Search only serves AMP from Cache for the following reasons:

  • Being able to pre-render a page without leaking privacy (all HTTP requests stays within CDN).
  • Page are validated and guaranteed be true AMP (no malicious JS, or low performing JS)

So it's about speed + privacy + security.

Worth to mention we're working on a web packaging based solution might address the problem.

@jasti jasti moved this from Next Up to Shipped in AMP HTML Project Roadmap Sep 19, 2018

@jeffjose jeffjose changed the title [Master feature] AMP ID link decoration [Master feature] AMP Linker Sep 19, 2018

@ampprojectbot

This comment has been minimized.

Copy link
Collaborator

ampprojectbot commented Jan 9, 2019

This issue hasn't been updated in awhile. @calebcordry Do you have any updates?

@calebcordry

This comment has been minimized.

Copy link
Member Author

calebcordry commented Jan 9, 2019

@jeffjose I think that this is complete. I will leave it up to you to close.

@shimonenator

This comment has been minimized.

Copy link

shimonenator commented Jan 16, 2019

@lannka I'd like to restart conversation about iframe id sharing. Assuming that it's async, and that iframe already can interact with AMP pages via postMessage for resize purposes, <amp-iframe> can also have an attribute that tells AMP Linker to pass parameters to it, which can be done via postMessage on iframe load. And the iframe can message out a request for linker to be passed to it.

@jeffjose

This comment has been minimized.

Copy link
Collaborator

jeffjose commented Jan 17, 2019

Hi @shimonenator, would you mind opening a new issue for this question? I want to make sure the question you're asking is answered properly and not buried inside a larger issue.

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.