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

I2I: Allow AdSense ad size optimization for <amp-ad> #23568

Open
riklund opened this issue Jul 29, 2019 · 4 comments
Open

I2I: Allow AdSense ad size optimization for <amp-ad> #23568

riklund opened this issue Jul 29, 2019 · 4 comments
Assignees
Labels
Component: AMPHTML ads INTENT TO IMPLEMENT Proposes implementation of a significant new feature. https://bit.ly/amp-contribute-code WG: monetization

Comments

@riklund
Copy link
Contributor

riklund commented Jul 29, 2019

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):

<amp-ad width=300 height=250
      type="adsense"
      data-ad-client="ca-pub-0123456789012"
      data-ad-slot="0123456789">
 </amp-ad>

Example localstorage content (opted in publisher):

key value
aas-ca-pub-0123456789012 1

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

@riklund riklund added the INTENT TO IMPLEMENT Proposes implementation of a significant new feature. https://bit.ly/amp-contribute-code label Jul 29, 2019
@zhouyx
Copy link
Contributor

zhouyx commented Jul 30, 2019

Thank you @riklund

Based on the design, all value will be calculated client side. The proposal LGTM.

@zhouyx
Copy link
Contributor

zhouyx commented Jul 30, 2019

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.

@lannka
Copy link
Contributor

lannka commented Jul 31, 2019

LGTMed

riklund added a commit to riklund/amphtml that referenced this issue Sep 5, 2019
riklund added a commit to riklund/amphtml that referenced this issue Sep 6, 2019
riklund added a commit to riklund/amphtml that referenced this issue Sep 6, 2019
riklund added a commit to riklund/amphtml that referenced this issue Sep 6, 2019
riklund added a commit to riklund/amphtml that referenced this issue Sep 6, 2019
riklund added a commit to riklund/amphtml that referenced this issue Sep 6, 2019
riklund added a commit to riklund/amphtml that referenced this issue Sep 9, 2019
riklund added a commit to riklund/amphtml that referenced this issue Sep 9, 2019
riklund added a commit to riklund/amphtml that referenced this issue Sep 9, 2019
riklund added a commit to riklund/amphtml that referenced this issue Sep 9, 2019
riklund added a commit to riklund/amphtml that referenced this issue Sep 30, 2019
riklund added a commit to riklund/amphtml that referenced this issue Oct 1, 2019
riklund added a commit to riklund/amphtml that referenced this issue Oct 1, 2019
@stale
Copy link

stale bot commented Jan 21, 2021

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.

@stale stale bot added the Stale Inactive for one year or more label Jan 21, 2021
@jridgewell jridgewell removed the Stale Inactive for one year or more label Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: AMPHTML ads INTENT TO IMPLEMENT Proposes implementation of a significant new feature. https://bit.ly/amp-contribute-code WG: monetization
Projects
None yet
Development

No branches or pull requests

4 participants