-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
I2I: Run 3p service scripts in AMP #30193
Comments
Do you have a list of use cases? I'm not against this, just want to make sure there is a broad set of use cases that both
|
Permutive's integration #28095 is the only use case I know right now. We have discussed with them offline on this approach. We thought about two potential use cases. One is client side ads targeting solution similar to the Permutive case. The other is to allow analytics vendors to compose their outgoing request in their custom way. But I'm not aware of any immediate use case apart from the Permutive request. We saw 21 thumbs up when the Permutive team asked for this feature: ) #28471 (comment) All, Please let us know if the proposed feature will be helpful. Thanks! |
This proposal would be extremely helpful in ensuring we have a product that covers a large part of our mobile inventory as it pertains to 1P audience targeting. |
We are not currently able to make the most of our increasingly mobile audience due to the AMP restrictions. This proposal would help us to better understand and activate this audience. |
This will be super helpful as it will allow publisher to unlock all their audiences on all platforms |
This would be huge for us, our mobile product optimisation is lacking in this space due to the limitations around our ability to unlock inventory for audience targeting. |
Add @lannka I'm not very familiar with that. What are the common audience targeting options available? I'd assume this is done on the server side, is client side audience targeting a very common approach? Thanks |
This feature would be terrific way for our Publisher Alliance audience based company, to reach audiences and do better targeting in AMP environment. |
Is this a case in which cookies support would be helpful? (Even though it sounds like cookies aren't needed for #28095) See also ampproject/worker-dom#451 . |
I think I have good news! A similar use-case for dynamically manipulated json was just solved for
Scripts in Note that I still do see some diffs in functionality between this I2I and current capabilities. E.g.
|
@samouri Wonderful, didn't know we have the Sounds to me this new A few notes
Because scripts are loaded from trusted service provider, we'd also like to remove the script hash requirement from
If Scripts in worker-dom can export functions for use in the main-thread we probably won't need to pass message back from worker to AMP. However to feed the worker with analytics data, we'd still need pass message to the worker.
We propose reusing the same worker due to the concern of the core number limit. It doesn't have to run in the same one, but I believe some type of worker number limit need to be applied. |
As a publisher who has worked with permutive for over 3 years now, we've benefited immensely from their technology's ability to maximise the visibility and targeting of our audiences. However, an ever-increasing proportion of our users engage with us in AMP environments and so this proposal would be hugely beneficial for us in the insights and targeting we can provide on these users. |
Being able to pass the permutive (or other DMP) data to our adserver is critical for our core business. We'd benefit a lot with this solution. |
We've got a lot of positive feedback on this proposal! Would someone from Permutive or other DMP take a look and let us know that the proposed solution could fulfill the audience targeting requirement. It would be helpful to get answers to the following questions
Thanks! |
Great to see the progress on finding a solution here! @zhouyx yes I believe the proposed solution would fulfil our audience targeting requirement, as long as there is a way to communicate targeting data back to amp-ad components from the worker. Removing the script hash requirement for trusted service providers will work well for our use case. Just to double check my understanding - how would we register as a trusted service provider? Would this be a case of us creating an To answer your questions:
The only data we’d expect to get is analytics events, triggered by our amp-analytics vendor config. Our script running in the worker should be able to consume this data. Also we may need to pass some publisher-provided config into the worker (e.g. when publisher configures
I believe the only data we’d need to pass back is targeting data to be used by amp-ads. This is essential for the audience targeting requirement. Ideally there will be a mechanism for publisher to configure their amp-ad to wait for our worker to return targeting data (similar to how RTC works with a timeout/max-wait)
Yes, our worker script would need access to storage. Not cookies, but ideally localStorage and IndexedDB (we rely on these storage mechanisms to cache state on non-AMP pages). We spoke about the limitations of storage on SERP in Safari previously @zhouyx (storage being limited to very few bytes due to it being stored on the google.com domain). Would our script be able to use storage without these strict limits outside of SERP in Safari (using the publisher CDN domain)? |
If you need to handle the response back from the worker specially, I think an amp-permutive component makes sense. However AMP's goal is to generalize the use cases. Can we expect the response to be in a standard format that a generalized component can handle?
Yes it's possible to expand the storage usage outside of AMP Viewer (when Storage API is not used). We currently don't have ways to retrieve localStorage value in amp-analytics. I assume that would be something you need as well. |
OK that makes sense, in that case we may be able to get away without an
That's great news! Will it be possible to read/write this storage directly from the worker script? Are there any local storage usage limits imposed here aside from the standard browser limits?
Not sure exactly what you meant here, I don't believe this is a requirement for our use case.
For now, we can ensure our worker script relies on local storage only (with a view to changing this if IndexedDB is supported in the future). |
We would be very interested in seeing this proposal progress, so we are able to target across our scaling amp inventory. Following for updates. |
Filed an I2I to expand the LocalStorage usage to all #30872 Let's bring the topic to the design review. Otherwise I don't see any blocker to building this messaging infrastructure and allow 3p scripts to run in AMP. |
@zhouyx: Is the plan to expand the functionality of |
Feedback from Design Review.
where no script hash will be required
|
bump on this, just so i stay in the thread and get notified on developments |
Summary
The AMP team decided to restrict all cross domain iframe running in the background. To allow 3p service providers to run their scripts in AMP document, we propose a workaround to run all 3p scripts in a web worker.
This is different from
<amp-script>
in two ways. 1. No DOM access or DOM change. 2. Scripts must come from publishers trusted service providers. (Provided by an AMP component)The following proposal serves as a workaround. It is still recommended that 3p service integrate with AMP as first party AMP component.
Design document
ScriptRunner
ServiceIt’s up to the 3P AMP component to define the communication API between its AMP component and the web worker via the listen and send method.
Worker Initialization & Termination
The Worker will be created lazily when
ScrptRunner.run()
is called the first time.Messages from AMP to the worker will be buffered for a certain time before the worker has been created.
The worker will remain alive. But AMP runtime may choose to terminate it after a certain timeout.
Multiple scripts
Only one web worker will be created for all 3rd party scripts to share.
Security Concern
We'll need to sandbox the web worker. (e.g. dereferencing Worker globals)
Based on the feedback from the security review. We need to place the web worker within a sandboxed cross origin iframe. The iframe will serve as a proxy to post messages between AMP and the web worker.
To be discussed: Given the sandbox iframe, do we still need to sandbox the web worker? (e.g fetching scripts)
AMP Analytics Integration
There's a request to feed the web worker with data from
<amp-analytics>
. We think this is reasonable and propose a new transport methodworker
(name tbd) to<amp-analytics>
Motivation
The Permutive needs to run their scripts to calculate
<amp-ad>
JSON config on the client side. While they're willing to introduce a<amp-permutive>
component, they can't generalize their publisher based solution. #28095Similar to why we introduce
<amp-script>
. Being able to run a small piece of their scripts may unblock more service providers from integrating to AMP.Additional context
Some 3P service providers integrates with AMP via running their scripts in an iframe. This has been discussed in Design Review #28471. AMP will no longer allow cross domain iframe running in the background (e.g.
<amp-pinterest>
is allowed because there's content) unless an exception has been made with review.Launch tracker
/cc @ampproject/wg-approvers @joshfg
The text was updated successfully, but these errors were encountered: