amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

need a way to collapse ads inside viewport [related to #3182]

Open lisamayo opened this issue 10 years ago • 10 comments

This question is related to issue #3182 -- if the ad is inside the viewport, what suggestions do you have to collapse it? We need some way to hide the empty 300x250 (or whatever size) amp-ad element that remains when no creative is returned. I understand there's concern over a flash/shifting of content but then how do we compensate for the space left behind?

lisamayo avatar Jul 19 '16 17:07 lisamayo

Provide a <div fallback> element inside the amp-ad

cramforce avatar Jul 19 '16 17:07 cramforce

Deets: https://github.com/ampproject/amphtml/blob/master/builtins/amp-ad.md#no-ad-available

jasti avatar Jul 19 '16 17:07 jasti

I tried that, along with sending noContentAvailable and requestResize when the ad receives a postMessage of 'no-content'. The inline style of the amp-div does not get reset to height: 0 or display:none. https://www.evernote.com/l/AZU7zyJRvFZCRI3XGRJ9jUBaf3w-Cg-qUhQ I'm testing this locally using code that I pulled from the amp repo this morning (EST).

lisamayo avatar Jul 19 '16 17:07 lisamayo

@lisamayo Here is a super simple test page where the fallback works - http://output.jsbin.com/laguleweru, when the adserver is DFP. Can you link a live test page? @zhouyx Sounds like our fallback looks for a select event from the ad server to replace with fallback content. Can you please confirm?

jasti avatar Jul 20 '16 21:07 jasti

when the amp-ad receive no-content message it will try to replace with fallback content ( if there's is one).
If there's no fallback content, amp-ad will try to collapse itself, but the attempt to change height to 0 may fail when the ad is in viewport.

zhouyx avatar Jul 20 '16 22:07 zhouyx

@lisamayo does adtech adserver respond back with a 'no-content' when there is no ad?

jasti avatar Jul 20 '16 22:07 jasti

@jasti : yes, adtech responds back with 'no-content' when there's no ad. But what @zhouyx mentions is what I'm seeing -- when the ad is in viewport it doesn't collapse (the height change to 0 doesn't happen) even with the 'no-content' message. If the ad is below the viewport then yes, it does collapse as expected.

In the meantime I spoke to our product team to find out if we could resolve this issue from their end; I was told that the plan is to always serve inventory so I don't need to worry about collapsing the spot. That being said, I am going to close out this out since it's no longer an issue for us (at least for now).

Thanks for help and the quick replies, much appreciated!

lisamayo avatar Jul 21 '16 15:07 lisamayo

@lisamayo I'm confused. @zhouyx said that when there's no fallback content. Thought you were trying this with fallback content. If no, we are all good here!

jasti avatar Jul 21 '16 15:07 jasti

Nope, I was trying it without fallback content...sorry for any confusion. All good now. :)

lisamayo avatar Jul 21 '16 15:07 lisamayo

Awesome.

jasti avatar Jul 21 '16 15:07 jasti