I'm using responsive Google Ads on my website but unfortunately it is not working all the time and most of time it is returning
TagError: adsbygoogle.push() error: No slot size for availableWidth=0
I tried to fix the issue by defining the Ad Sizes but still the issue is not resolved yet.
.adslot_1 { width: 320px; height: 100px; } @media (min-width:500px) { .adslot_1 { width: 468px; height: 60px; } } @media (min-width:800px) { .adslot_1 { width: 728px; height: 90px; } } @media only screen and (min-width:800px)and (max-width:3000px) { #topbanner { width: 640px; height: 90px; } }
Well, this is the actual Google Adsense Google Code that I've used (for security reasons I've remove pub-id and ad-slot.)
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- articles(auto) --> <ins class="adsbygoogle adslot_1" style="display:inline-block;" data-ad-client="ca-pub-[MY_AD_ID]" data-ad-slot="AD_SLOT_NOS" data-ad-format="rectangle, horizontal"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
I used:
window.onload = function() { (adsbygoogle = window.adsbygoogle || []).push({}); }
My site was loading pages in a special way, making heavy use of AJAX, so it had to be this way. Hope this helps someone.
EDIT 2018: I feel like I should mention now that the preferred way to do this would be with window.addEventListener( 'load', ... )
, instead of the old method of window.onload = ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With