collapse ad space issues
Let me start by saying that I know if an ad is not in view, no ad loads, and there's no fallback that the ad space will collapse. But we have the need to run blank ads for reporting and for ad bundle purchasing and we need these blank ads to collapse the ad space. So then I recently learned of the context.noContentAvailable() function which collapses the ad space but kills the content of the iframe which doesn't allow the impression to load so there is no tracking. So how can I kill the ad space but still have an impression load. I'm trying to specifically solve for the "sticky" ad space, but my question applies to any ad space. I have also tried window.context.requestResize(0,0); but it wasn't executing (and strangely I wasn't seeing the onResizeSuccess or onResizeDenied listeners fire).
Here's a test url where currently I am using context.noContentAvailable(). You can see the view?xai=... in the network tab is cancelled - that's the impression failing to load.
http://www.cbsnews.com/amp/news/james-comey-fired-fbi-director-in-2014-60-minutes/?adNetwork=7336&adtargeting_campaign=sticky_7336
@lannka @ampproject/a4a
@coreybyrnes just try to understand your problem: so you want to count an "impression" (i actually would not call this an "impression") even when the ad slot does not get filled with an ad? Is it to calculate a fill rate? If not, what's your real use case?
/cc @zhouyx
@lannka But it is being filled with an ad... just a blank one. ;) We do this in almost all our ad slots across the entire CBSi network of sites - when no ad is running, we run a blank creative that collapses the space. There are many reasons/cases for it, but for example one case is when an advertiser purchases a complete buyout of all ad slots on the page but doesn't have a creative for a particular slot (to guarantee no other advertiser's ad runs in that slot).
Have you considered trying to resize the creative to 0x0 instead of noContent? I believe noContent causes the frame to be removed while resize should leave it in place but with no size allowing the delayed impression to potentially fire.
@keithwrightbos thanks for the reply, but as I stated in the original post the resizeRequest isn't working and the resize events aren't firing. So not sure what's causing that, but this specific case is slightly more complex because I'm trying to collapse the sticky component which is the parent to the ad slot so I'm unsure if a resize would reach that far up.
Apologies, I missed that! Sounds like investigating why resizeRequest is not working is the ideal solution. Definitely odd and needs to be run down.
@keithwrightbos no worries!
@lannka @zhouyx let me know what you think! I can update my test url (posted in the original post) to be using context.requestResize(0,0) instead of context.noContentAvailable if that seems to be a better option. Then we can attempt to diagnose why it's not executing and if it will collapse the sticky component at the same time?
@coreybyrnes FYI: we don't allow resizing for sticky ad component, I think that's why context.requestResize(0, 0) doesn't work.
I still trying to understand why you still want to keep the iframe after ad collapse.
for example one case is when an advertiser purchases a complete buyout of all ad slots on the page but doesn't have a creative for a particular slot (to guarantee no other advertiser's ad runs in that slot).
But it won't run other advertiser's ad either after we kill the iframe? Or do you need to keep the iframe to calculate total impression time or so?
@zhouyx, if I understand this use case correctly, the iframe only needs to be kept alive long enough to ensure that the delayed impression beacon has a chance to fire, for accounting purposes. In the above link, it was showing up as "(canceled)" in the Chrome dev tools.
Thanks @taymonbeal
@coreybyrnes If that is the case, iframe has full control on when to send no-content. would sending no-content after impression tracking finish help?
@taymonbeal Thanks for chiming in and clarifying.
@zhouyx I don't have control over when the impression fires - it's controlled by DFP. I will investigate if I can override that and manually fire it for this sticky slot only, but I know that won't be a universal option for all our slots so the original question/issue still stands.
@zhouyx @lannka I tried manually firing an impression before calling noContentAvailable but it doesn't work. The ad network inserts the scripts that handle the impression after the creative code, so as soon as you call noContentAvailable everything is wiped. I tried to set up a timer to call noContentAvailable after 10s but it never fired.
Ideally there would be a new function, something like collapseSlot, that would simply set the ad call to display:none and also see if the ad call was nested inside a component like the sticky or flying-carpet and collapse that as well. Thoughts?
@coreybyrnes, what happens if you try putting the call to noContentAvailable inside an onload event listener?
@taymonbeal Thanks for the suggestion, but it unfortunately didn't fire. I'm sure there's a reason, but it seems like noContentAvailable won't execute if there's any delay either through a timer or waiting for the onload event. Here's what I tried (and I do see the log in the console):
window.addEventListener('load', function(){ console.log('window loaded'); window.parent.context.noContentAvailable(); }, false);
You can see this on the test url from the original comment: http://www.cbsnews.com/amp/news/james-comey-fired-fbi-director-in-2014-60-minutes/?adNetwork=7336&adtargeting_campaign=sticky_7336
Ah, I think I know what's wrong here! The relevant postMessage listener listens for only one message, which can be either render-start or no-content. Once it's received one, it stops listening and any further messages are ignored.
Fellow maintainers: would you be in favor of changing this so that noContentAvailable() can be called at any time?
@taymonbeal thanks for making that discovery!
I am not sure about handling no-content after render-start. The point of render-start is to inform AMP runtime when the ad starts rendering and set the ad visible to user. So I think it's quite reasonable for AMP runtime to assume only one message will be received.
In the special case for sticky ad. Once AMP runtime receive render-start it will unhide the ad. Upon receiving another no-content, runtime will hide the ad again. In this case user will notice a blank ad blink, which is exactly what we want to avoid.
@zhouyx @taymonbeal But I am able to run a creative that calls noContentAvailable() and it does indeed kill the iframe and in the case of the sticky it doesn't ever appear - no "blink". It's only if I try to call noContentAvailable after a delay via setTimeout or waiting for the window.onload event that it won't execute. But we need to delay it until the impression has successfully rendered.
@coreybyrnes delaying the call to noContentAvailable should work. I used to delay the signal by few seconds during manual testing and it works as expected. When you delay the call to noContentAvailable, do you have control of renderStart? I assume it's possible that renderStart is called by nested window since impression has successfully rendered.
@zhouyx I don't believe I have control over renderStart, but I'm really not sure how/when that is fired. Perhaps it is tied to the impression? Really not sure, but it seems like if the impression successfully fires then noContentAvailable cannot execute.