I2I [amp-analytics]: Custom event trigger for 3p extensions #6417

Closed
lannka opened this Issue Nov 30, 2016 · 19 comments

Comments

Projects
None yet
9 participants
@lannka
Collaborator

lannka commented Nov 30, 2016

This is for 3Ps (A4A networks, video players and others like facebook, twitter etc) to track how their AMP extensions perform, so that they can tune their products, detect and respond to issues, etc.

For that purpose, A4A has created a temporary solution for performance reporting. Meantime, more similar requirements are coming: #6306.

For sake of performance, it will be good to leverage the existing amp-analytics infrastructure to manage those pings altogether with other ones.

Note that in normal use cases, the data collected by amp-analytics is consumed by the publishers. The new proposed use case here are for 3Ps. So we'd be careful and prevent any sensitive data being accessed by 3P. On other hand, we already have use cases, such as A4A ActiveView tracking, of which the data are consumed not by publisher, but by 3Ps (advertisers).

Vendor config
All 3Ps want to enable this feature need to write their own analytics vendor config, like what we have in vendor.js. The scope of the config should be restricted to the extension only. So that extensions cannot interfere each other.

some3p: {
  "requests": {
    "event": "https://3p.com/event?eventName=${event}&eventAttributes=${attributes}"
  },
  "triggers": {
    "CustomEvent": {
      "on": "custom-event",
      "request": "event",
    },
  }
}

Usage
3P will report a custom event like this:

customEventTrackerFor(doc, 'some3p').then(tracker => {
  tracker.trackEvent('event-name', { attr1: 'value1', attr2: 'value2' });
};

Limitation

  • No pings for pages that don't have amp-analytics installed.
  • The pings are asynchronous, which might introduce inaccuracy to latency calculation.

Alternative
3P can do ad-hoc pings like

new Image().src = $URL

@avimehta @cramforce @dvoytenko @rudygalfi @ericlindley-g @tdrl @keithwrightbos @jasti thoughts?

@keithwrightbos

This comment has been minimized.

Show comment
Hide comment
@keithwrightbos

keithwrightbos Nov 30, 2016

Collaborator

Agree that usage of amp-analytics would be ideal both for CSI and network specific error reporting in both A4A in 3p. In fact, I was going to propose such a thing to address #6306. We would need a way for 3p networks to register their callback locations presumably within ads/_config.js

Question is whether there would be any additional, network specific variables that a network would want to attached (e.g. network specific data attributes on the amp-ad element)? How would we support such a thing (presumably via url replacement)?

Collaborator

keithwrightbos commented Nov 30, 2016

Agree that usage of amp-analytics would be ideal both for CSI and network specific error reporting in both A4A in 3p. In fact, I was going to propose such a thing to address #6306. We would need a way for 3p networks to register their callback locations presumably within ads/_config.js

Question is whether there would be any additional, network specific variables that a network would want to attached (e.g. network specific data attributes on the amp-ad element)? How would we support such a thing (presumably via url replacement)?

@lannka

This comment has been minimized.

Show comment
Hide comment
@lannka

lannka Nov 30, 2016

Collaborator

The vendor config can definitely go places like ads/_config.js.

For 3P specific metrics, you put them as attributes

tracker.trackEvent('render-start', { slotId: '123', timestamp: 12345 });
Collaborator

lannka commented Nov 30, 2016

The vendor config can definitely go places like ads/_config.js.

For 3P specific metrics, you put them as attributes

tracker.trackEvent('render-start', { slotId: '123', timestamp: 12345 });
@tdrl

This comment has been minimized.

Show comment
Hide comment
@tdrl

tdrl Nov 30, 2016

Contributor

This looks excellent. It would be a huge benefit to A4A. A couple of refinement questions:

  • I'm not clear how this works for 3p implementations. Aren't they running in x-domain iframes with no AMP runtime? How would they access the tracker machinery?
  • Would some or all of the standard analytics variables be available? I'm thinking of stuff like viewport dimensions and ad offset within viewport.
  • Would sampling / throttling be available, as in analytics? (I assume yes, since I read this as an extension of analytics.)
    • Following on that: notions of priority? There are some things that we want guaranteed delivery of (to the extent possible) and there are some lower priority things that we're okay if some fraction of them get lost.
Contributor

tdrl commented Nov 30, 2016

This looks excellent. It would be a huge benefit to A4A. A couple of refinement questions:

  • I'm not clear how this works for 3p implementations. Aren't they running in x-domain iframes with no AMP runtime? How would they access the tracker machinery?
  • Would some or all of the standard analytics variables be available? I'm thinking of stuff like viewport dimensions and ad offset within viewport.
  • Would sampling / throttling be available, as in analytics? (I assume yes, since I read this as an extension of analytics.)
    • Following on that: notions of priority? There are some things that we want guaranteed delivery of (to the extent possible) and there are some lower priority things that we're okay if some fraction of them get lost.
@lannka

This comment has been minimized.

Show comment
Hide comment
@lannka

lannka Nov 30, 2016

Collaborator

I'm not clear how this works for 3p implementations. Aren't they running in x-domain iframes with no AMP runtime? How would they access the tracker machinery?

It's not for things in 3p iframe. I was referring to 3P's extension, such as facebook.js

Would some or all of the standard analytics variables be available? I'm thinking of stuff like viewport dimensions and ad offset within viewport.
Would sampling / throttling be available, as in analytics? (I assume yes, since I read this as an extension of analytics.)

Yes, we will get features from amp-analytics. That's the benefit of reusing the infrastructure.

Collaborator

lannka commented Nov 30, 2016

I'm not clear how this works for 3p implementations. Aren't they running in x-domain iframes with no AMP runtime? How would they access the tracker machinery?

It's not for things in 3p iframe. I was referring to 3P's extension, such as facebook.js

Would some or all of the standard analytics variables be available? I'm thinking of stuff like viewport dimensions and ad offset within viewport.
Would sampling / throttling be available, as in analytics? (I assume yes, since I read this as an extension of analytics.)

Yes, we will get features from amp-analytics. That's the benefit of reusing the infrastructure.

@keithwrightbos

This comment has been minimized.

Show comment
Hide comment
@keithwrightbos

keithwrightbos Nov 30, 2016

Collaborator
Collaborator

keithwrightbos commented Nov 30, 2016

@tdrl

This comment has been minimized.

Show comment
Hide comment
@tdrl

tdrl Nov 30, 2016

Contributor

Re 3p: Sounds like Keith and Hongfei have different visions of what we mean by 3p in this context. Maybe we should try to video chat to clarify?

Also, meant to ask before: Do you have a projected ETA on this? Anything we can do to help directly? This would enable some fairly high priority monitoring for us.

Contributor

tdrl commented Nov 30, 2016

Re 3p: Sounds like Keith and Hongfei have different visions of what we mean by 3p in this context. Maybe we should try to video chat to clarify?

Also, meant to ask before: Do you have a projected ETA on this? Anything we can do to help directly? This would enable some fairly high priority monitoring for us.

@lannka

This comment has been minimized.

Show comment
Hide comment
@lannka

lannka Nov 30, 2016

Collaborator

There is no conflict between what Keith and I were thinking. Those 3p ads events processed in AMP runtime, such as render-start no-content, are definitely able to get reported. We just need to make sure the right vendor config is picked during runtime (don't ping A9 ad server for Doubleclick ads).

For timeline, I agree this is important as we've talked about many times. Still want to get some feedback from PMs though, to see if this is something we can make available to any 3Ps.

Collaborator

lannka commented Nov 30, 2016

There is no conflict between what Keith and I were thinking. Those 3p ads events processed in AMP runtime, such as render-start no-content, are definitely able to get reported. We just need to make sure the right vendor config is picked during runtime (don't ping A9 ad server for Doubleclick ads).

For timeline, I agree this is important as we've talked about many times. Still want to get some feedback from PMs though, to see if this is something we can make available to any 3Ps.

@dvoytenko

This comment has been minimized.

Show comment
Hide comment
@dvoytenko

dvoytenko Dec 1, 2016

Collaborator

@lannka Analytics currently provides triggerEvent public method that other components (e.g. carousel) use to trigger their custom events. Could you summarize how this would be different?

Collaborator

dvoytenko commented Dec 1, 2016

@lannka Analytics currently provides triggerEvent public method that other components (e.g. carousel) use to trigger their custom events. Could you summarize how this would be different?

@lannka

This comment has been minimized.

Show comment
Hide comment
@lannka

lannka Dec 1, 2016

Collaborator

@dvoytenko implementation wise, the work will be

  • make Analytics a service, and expose triggerEvent
  • introduce additional 3P vendor settings sanboxed in 3P extensions, meaning an extension would only ping its own analytics server.
  • Limit sensitive data access.

BTW, I don't see carousel firing custom events for analytics in the code, since analytics is not a service yet.

Collaborator

lannka commented Dec 1, 2016

@dvoytenko implementation wise, the work will be

  • make Analytics a service, and expose triggerEvent
  • introduce additional 3P vendor settings sanboxed in 3P extensions, meaning an extension would only ping its own analytics server.
  • Limit sensitive data access.

BTW, I don't see carousel firing custom events for analytics in the code, since analytics is not a service yet.

@dvoytenko

This comment has been minimized.

Show comment
Hide comment
@dvoytenko

dvoytenko Dec 1, 2016

Collaborator

It is exposed already. See triggerAnalyticsEvent.

Collaborator

dvoytenko commented Dec 1, 2016

It is exposed already. See triggerAnalyticsEvent.

@ericlindley-g

This comment has been minimized.

Show comment
Hide comment
@ericlindley-g

ericlindley-g Dec 8, 2016

Collaborator

@lannka Is there an outstanding feature to implement here, or should this issue be closed?

Collaborator

ericlindley-g commented Dec 8, 2016

@lannka Is there an outstanding feature to implement here, or should this issue be closed?

@ericlindley-g ericlindley-g modified the milestones: Pending 3P Implementation, Pending Triage Dec 8, 2016

@lannka

This comment has been minimized.

Show comment
Hide comment
@lannka

lannka Dec 8, 2016

Collaborator

@ericlindley-g Still working with @dvoytenko to figure out the work.

Collaborator

lannka commented Dec 8, 2016

@ericlindley-g Still working with @dvoytenko to figure out the work.

@lannka lannka changed the title from I2I: Custom event trigger in amp-analytics to I2I [amp-analytics]: Custom event trigger for 3p extensions Dec 8, 2016

@lannka lannka modified the milestones: Next, Pending Triage Jan 31, 2017

@rudygalfi rudygalfi added this to Sprint Candidate in Analytics Feb 3, 2017

@rudygalfi rudygalfi added the P2: Soon label Feb 8, 2017

@rudygalfi rudygalfi moved this from Sprint Candidate to Backlog in Analytics Feb 13, 2017

@rudygalfi

This comment has been minimized.

Show comment
Hide comment
@rudygalfi

rudygalfi Feb 13, 2017

Contributor

Per Sprint Planning, not doing this in upcoming sprint.

Contributor

rudygalfi commented Feb 13, 2017

Per Sprint Planning, not doing this in upcoming sprint.

@lannka lannka moved this from Backlog to Sprint Candidate in Analytics Feb 24, 2017

@rudygalfi rudygalfi moved this from Sprint Candidate to In Progress This Sprint in Analytics Feb 27, 2017

@zhouyx

This comment has been minimized.

Show comment
Hide comment
@zhouyx

zhouyx Mar 2, 2017

Collaborator

Talked to @dvoytenko We will go with the straightforward way in V0.

  • Provide analytics to extension element by creating element and adding to DOM

  • Privacy review happens during PR review. We do not support remote config.

Collaborator

zhouyx commented Mar 2, 2017

Talked to @dvoytenko We will go with the straightforward way in V0.

  • Provide analytics to extension element by creating element and adding to DOM

  • Privacy review happens during PR review. We do not support remote config.

@oliverfernandez

This comment has been minimized.

Show comment
Hide comment
@oliverfernandez

oliverfernandez Mar 4, 2017

Contributor

I can't help but thinking that somehow this can be related to #6234: leverage amp-analytics to be able to send custom events from a IFRAMEs, like video players. Makes sense?

I'd like to consider here AMP Shadow too. It would be super useful to have a standard way to to communicate from the shell to AMP in order to send analytics events, other than manually accessing the instrumentation service (our current approach)

I believe that it's possible to have a common solution (event based?) to cover all 3 cases

  • 3P extensions
  • IFRAMEs
  • Shells that use AMP Shadow API

What do you think?

Contributor

oliverfernandez commented Mar 4, 2017

I can't help but thinking that somehow this can be related to #6234: leverage amp-analytics to be able to send custom events from a IFRAMEs, like video players. Makes sense?

I'd like to consider here AMP Shadow too. It would be super useful to have a standard way to to communicate from the shell to AMP in order to send analytics events, other than manually accessing the instrumentation service (our current approach)

I believe that it's possible to have a common solution (event based?) to cover all 3 cases

  • 3P extensions
  • IFRAMEs
  • Shells that use AMP Shadow API

What do you think?

@dvoytenko

This comment has been minimized.

Show comment
Hide comment
@dvoytenko

dvoytenko Mar 10, 2017

Collaborator

Good point, re: shadow API. We definitely want a clear mechanism to forward them to shell.

Collaborator

dvoytenko commented Mar 10, 2017

Good point, re: shadow API. We definitely want a clear mechanism to forward them to shell.

@zhouyx zhouyx referenced this issue Mar 16, 2017

Closed

Extension Analytics V1 #8202

10 of 10 tasks complete

@rudygalfi rudygalfi moved this from In Progress This Sprint to Sprint Candidate in Analytics Mar 27, 2017

@rudygalfi rudygalfi moved this from Sprint Candidate to On Deck for Next Sprint in Analytics Mar 30, 2017

@rudygalfi

This comment has been minimized.

Show comment
Hide comment
@rudygalfi

rudygalfi Mar 30, 2017

Contributor

@zhouyx Can you amend the initial posting to include a task breakdown checklist, so we can get visibility into this as a multi-sprint effort?

Contributor

rudygalfi commented Mar 30, 2017

@zhouyx Can you amend the initial posting to include a task breakdown checklist, so we can get visibility into this as a multi-sprint effort?

@zhouyx

This comment has been minimized.

Show comment
Hide comment
@zhouyx

zhouyx Mar 30, 2017

Collaborator

task breakdown checklist: #8202

Collaborator

zhouyx commented Mar 30, 2017

task breakdown checklist: #8202

@rudygalfi

This comment has been minimized.

Show comment
Hide comment
@rudygalfi

rudygalfi Mar 30, 2017

Contributor

We're going to track this in #8202 going forward and close this issue.

Contributor

rudygalfi commented Mar 30, 2017

We're going to track this in #8202 going forward and close this issue.

@rudygalfi rudygalfi closed this Mar 30, 2017

@rudygalfi rudygalfi removed this from the Sprint H1 April milestone Mar 30, 2017

@rudygalfi rudygalfi removed this from On Deck for Next Sprint in Analytics Mar 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment