AMP page, when visited via Google search and then refreshed, has missing window.context for 3p ads
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:
- Search for "enough is enough reuters" on google on a mobile browser
- Navigate to first AMP page
- Scroll down to the very first AMP unit
- You will see the ad render
- Scroll up (or don't) and refresh the page
- Scroll back down to the ad unit
Expected result:
- Ad renders
Observed result:
- Ad does not render and
window.contextis missing
Browser affected:
All browsers, including desktop Chrome in emulation mode.
AMP Version:
1499807487098
@harquail FYI.
There seem to be two versions of the page:
- https://www.google.com/amp/mobile.reuters.com/article/amp/idUSKBN18U0VV
- 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?
(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
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.
Thanks for handling this and finding out the root issue! Really appreciate it!
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!
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.
They should use the data based attribute until our fix for json based has been deployed to production (sometime next week)
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>
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?
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-rao, could you opt into AMP Dev Channel and then verify that data-use-same-domain-rendering-until-deprecated works now?
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.
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.
No worries - thanks a bunch for confirming, @taymonbeal