angular-google-adsense
angular-google-adsense copied to clipboard
adsbygoogle.push() error: No slot size for availableWidth=0
I'm using adsense responsive unit in a bootstrap layout. I've placed 2 adsense directives in two different areas of page: block1 and block2.
- block1 is only visible for widescreens (css class: hidden-xs, hidden-sm, hidden-md)
- block2 is only visible for mobile device (css class: hidden-lg)
So I get "adsbygoogle.push() error: No slot size for availableWidth=0" from adsense directive applied to hidden block. Yes, I know because hidden-* class applies display:none; the availableWidth is zero, but I'm following official adsense guidelines
What's wrong?
I suppose that (adsbygoogle = window.adsbygoogle || []).push({}) in visibile block affects also the hidden block. Did someone experience this scenario?
Hi. i'm having the same problem. Do you resolved?
Initially I found this https://stackoverflow.com/questions/40112557/adsense-responsive-no-slot-size-for-availablewidth-0 However my workaround is to use two differents ad slots for block1 and block2. I was using the same ad slot. I suppose that it's not allowed, also if one only of those is visible at the same moment. They are initialized regardless of visibility.
I think that this issue is related to the data-ad-format attribute. I removed the attribute from the ins tag. After this, checked if the display was set to block and, finally, added the attribute.
<div class="hidden-md hidden-lg">
<ins class="adsbygoogle" style="display:block"
data-ad-client="ca-pub-XXXXXXXXXXXXXXXX"
data-ad-slot="XXXXXXXXXX"></ins>
<script>
var el = document.querySelector('.hidden-md, .hidden-lg');
var display = window.getComputedStyle(el, null).getPropertyValue('display');
var ins = el.querySelector('ins');
if (display === 'block'){
ins.setAttribute('data-ad-format', 'auto');
}
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
some problems for my website error is: O {message: "adsbygoogle.push() error: No slot size for availableWidth=0", name: "TagError", pbr: true, stack: "TagError: adsbygoogle.push() error: No slot size f…esyndication.com/pagead/js/adsbygoogle.js:73:357)"} my website is PHP Coding Stuff help me please fast