Open riklund opened 5 years ago
Thank you @riklund
Based on the design, all value will be calculated client side. The proposal LGTM.
Looks like we need at least three approvers approval. https://github.com/ampproject/amphtml/blob/master/contributing/contributing-code.md#process-for-significant-changes
I believe we've already got @cramforce's approval on this usage offline. @lannka Could you please take a look given this is ad related. Then we can proceed with the change. Thanks.
LGTMed
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
Summary
AdSense allows a per publisher server side setting for changing the ad size to responsive on mobile. We'd like to support this on AMP too.
Design
Retrieving server side settings
An ad creative returned from the AdSense ad server may contain the publisher opt in status to this feature. It will then be sent to the parent window, from the creative, using a post message.
We intend to install an event listener, very similar to this one, which will handle the setting response from the ad creative. Once we receive a setting response, we will check whether the publisher is opted in or not, and store the opt in status to localstorage under the key
aas-${data-ad-client}
where${data-ad-client}
is a value specified directly on the ad slot.Example ad slot (non-responsive):
Example localstorage content (opted in publisher):
Using settings
As early as possible when constructing an AdSense ad slot on an AMPHTML page, we will look up the value for key
aas-${data-ad-client}
in localstorage. If the value is set and true, we will try to set the size of the responsive slot according to the standard AdSense responsive size logic, which is available here.Note that this approach means that the first time a user visits a particular site, the settings won't be available yet, and we'll use the non-responsive ad size.
We only intend to support this feature for the a4a path.
Motivation
This change gives AdSense publishers feature parity on AMP compared to non-AMP with respect to the auto ad size optimization option. The server side opt in provides a convenient way for publishers to take advantage of the benefits of using a responsive ad format without having to re-tag their pages.
/cc @ampproject/wg-approvers @charliereams @tlong2 @wjfang @lannka @zhouyx @keithwrightbos