I2I [amp-analytics]: Custom event trigger for 3p extensions
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-analyticsinstalled. - 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?
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)?
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 });
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.
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.
My thoughts:
- 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?
- For 3p ad networks, the would register in the 3p config the url to be called for various events (eg doubleclick desire to be notified when we never receive a render-start or no-content post message). The events and amp-analytics tag would be within the publisher page where AMP runtime is running, not the 3p, x-domain frame.
- 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.
- I assume we would follow whatever priority is given to amp-analytics
On Wed, Nov 30, 2016 at 2:57 PM Terran Lane [email protected] wrote:
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.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ampproject/amphtml/issues/6417#issuecomment-263977750, or mute the thread https://github.com/notifications/unsubscribe-auth/ABr0LxfsymmQLLYuKJXtPSWiG60AIoavks5rDdUbgaJpZM4LAk7g .
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.
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.
@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?
@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.
It is exposed already. See triggerAnalyticsEvent.
@lannka Is there an outstanding feature to implement here, or should this issue be closed?
@ericlindley-g Still working with @dvoytenko to figure out the work.
Per Sprint Planning, not doing this in upcoming sprint.
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.
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?
Good point, re: shadow API. We definitely want a clear mechanism to forward them to shell.
@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?
task breakdown checklist: #8202
We're going to track this in #8202 going forward and close this issue.