amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

AMP page, when visited via Google search and then refreshed, has missing window.context for 3p ads

Open ghost opened this issue 9 years ago • 15 comments

We had a publisher complaining about our ad units (that are being served via DFP on AMP) not rendering. Upon further investigation, we discovered that it was because our scroll listeners weren't being invoked, which led to us discovering that window.context was missing.

Steps to reproduce:

  1. Search for "enough is enough reuters" on google on a mobile browser
  2. Navigate to first AMP page
  3. Scroll down to the very first AMP unit
  4. You will see the ad render
  5. Scroll up (or don't) and refresh the page
  6. Scroll back down to the ad unit

Expected result:

  1. Ad renders

Observed result:

  1. Ad does not render and window.context is missing

Browser affected:

All browsers, including desktop Chrome in emulation mode.

AMP Version:

1499807487098

ghost avatar Jul 17 '17 22:07 ghost

@harquail FYI.

ghost avatar Jul 17 '17 22:07 ghost

There seem to be two versions of the page:

  1. https://www.google.com/amp/mobile.reuters.com/article/amp/idUSKBN18U0VV
  2. https://www.google.com/amp/uk.mobile.reuters.com/article/amp/idUSKBN18U0VV

Num 2 (uk.mobile.reuters.com) loads the ad unit every time. The first, never does. Are you sure the ad is being fulfilled correctly?

jridgewell avatar Jul 17 '17 23:07 jridgewell

(Noting that the migration for the context API implementation has been unlaunched, so this issue should be unrelated to that.)

Looks related to a FastFetch/AmpContext binary issue. Will update as I have new information.

/cc @bradfrizzell @keithwrightbos

alanorozco avatar Jul 18 '17 00:07 alanorozco

Looking into this, it appears that the publisher is specifying useSameDomainRenderingUntilDeprecated via the json attribute:

json="{"targeting":{"articleId":["USKBN18U0VV"]},"useSameDomainRenderingUntilDeprecated":1}"

Fast Fetch only looks for userSameDomainRenderingUntilDeprecated as an attribute as opposed to potentially inflating as is done for window context (see 3p-frame.js#addDataAndJsonAttributes_). We will fix this for fast fetch (thanks for finding it!). In the interim, the pub can correct by making useSameDomainRenderingUntilDeprecated as a explicit attribute on amp-ad element instead of passing within json.

Note that useSameDomainRenderingUntilDeprecated is going to be removed in the near future in favor of requiring the creative to load an API in order to communicate with the outer AMP runtime. We will share details on future integration in the near future.

keithwrightbos avatar Jul 18 '17 13:07 keithwrightbos

Thanks for handling this and finding out the root issue! Really appreciate it!

ghost avatar Jul 19 '17 14:07 ghost

Hey @keithwrightbos ; our publisher just got back to us with an issue; they made the change and added useSameDomainRenderingUntilDeprecated as an attribute on the amp-ad element. This is resulting in their AMP pages being invalidated; https://search.google.com/test/amp?id=C-JNTWueYXUNdVXdHN6JtQ

Is there another workaround we can recommend them? Thanks again!

ghost avatar Jul 19 '17 14:07 ghost

Your publisher is using the wrong syntax. Either use the attribute data-use-same-domain-rendering-until-deprecated, or else add "useSameDomainRenderingUntilDeprecated":true to the json attribute.

taymonbeal avatar Jul 19 '17 15:07 taymonbeal

They should use the data based attribute until our fix for json based has been deployed to production (sometime next week)

keithwrightbos avatar Jul 19 '17 15:07 keithwrightbos

Ah! Thank you so much @keithwrightbos and @taymonbeal .

I'll have them make it <amp-ad data-use-same-domain-rendering-until-deprecated type...></amp-ad>

ghost avatar Jul 19 '17 15:07 ghost

oh I'm so sorry, I just realized that we're actually looking for useSameDomainRenderingUntilDeprecated like you had which is not valid... (see https://github.com/ampproject/amphtml/blob/master/extensions/amp-ad-network-doubleclick-impl/0.1/doubleclick-a4a-config.js#L86). The error page you referenced seems to indicate they're adding it in all lowercase. Is that true? Did they try camel-case?

keithwrightbos avatar Jul 19 '17 15:07 keithwrightbos

thanks @keithwrightbos, I wanted to confirm that

<amp-ad width=300 height=250 type="doubleclick" data-slot="/4735792/amp.us.reuters/life/health/article" useSameDomainRenderingUntilDeprecated='1' json='{"targeting":{"articleId":["USKBN1A40UX"]}}'> </amp-ad>

is what AMP is looking for though the validator will report it as an error?

yieldmo-peter avatar Jul 19 '17 18:07 yieldmo-peter

@yieldmo-rao, could you opt into AMP Dev Channel and then verify that data-use-same-domain-rendering-until-deprecated works now?

taymonbeal avatar Jul 20 '17 20:07 taymonbeal

Hey @taymonbeal , thanks for that. Just to make sure, could you please confirm if this is what the final syntax will look like:

<amp-ad data-use-same-domain-rendering-until-deprecated type="doubleclick" other-attributes></amp-ad>

And NOT

<amp-ad data-useSameDomainRenderingUntilDeprecated="1" type="doubleclick" other-attributes></amp-ad>

OR <amp-ad useSameDomainRenderingUntilDeprecated="1" type="doubleclick" other-attributes></amp-ad>, and also confirm that the json way for supporting it will not be a part of the next release?

I ask because there have been a few parallel discussions on this thread, so thought I'd consolidate them, because that's what we'll be asking our publishers to implement tomorrow.

ghost avatar Jul 20 '17 21:07 ghost

Sorry for not clarifying. The correct syntax is data-use-same-domain-rendering-until-deprecated. The JSON way may be supported later, but not in the next release.

taymonbeal avatar Jul 21 '17 11:07 taymonbeal

No worries - thanks a bunch for confirming, @taymonbeal

ghost avatar Jul 21 '17 16:07 ghost