'Collapsing Google Adsense Divs
I have read a number of discussions on this, however most are related to using Google Publisher Tags and not responsive ads.
I have set responsive ads from within Adsense to "Collapse this adunit, otherwise show a blank space"
The problem is that my first ad unit on the page always shows a blank 280x300 blank space on mobile devices.
All of the other adspaces collapse as expected. I tried to remove the top advertisement (above the fold). When I do this, the 2nd ad unit (which is now the 1st) is showing a large 280x300 blank space.
It will initially be collapsed on load, then quickly expands to show a blank space.
I have tested this on both samsung browser and chrome mobile browser. This is creating a problem as I now have a large blank space above the fold. I have also set my adsense display balance to 60% so a blank adspace happens frequently.
I am using the following code (fairly standard adsense code)
<div class="bottommargin-sm">
<ins class="adsbygoogle"
style="display:block;"
data-ad-client="ca-pub-xxxx"
data-ad-slot="xxxx"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>'
The only solution I have seen is this https://support.google.com/admanager/answer/3072674?hl=en however this is not for responsive ads that I have setup
Other things I have tried include: loading a dummy ad unit first with display set to none, disabling async, changing parent div to row/container-fluid. Disabling Addthis/OneSignal plugins, disabling cloudflare rocketloader, adding 100%/auto width/height, adding overflow:hidden to parent div. Surround the window.adsbygoogle code with window.onload = function(){.
Another option I thought I could try would be to migrate to DoubleClick and I assume they would have away to manage this situation?
Solution 1:[1]
Ok this problem had been annoying me for so long. Google now has a solution. You can add the following CSS to your stylesheet
ins.adsbygoogle[data-ad-status="unfilled"] {
display: none !important;
}
Reference: https://support.google.com/adsense/answer/10762946?hl=en
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ryan NZ |