Google Adsense Error “TagError: adsbygoogle.push() error: No slot size for availableWidth=0 ”

后端 未结 13 1393
梦如初夏
梦如初夏 2021-01-31 08:56

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.pus

相关标签:
13条回答
  • 2021-01-31 09:26

    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 = ...

    0 讨论(0)
  • 2021-01-31 09:26

    In our case, we had problem displaying two banners but only in Chrome. First banner would not show and it would generate error:

    No slot size for availableWidth=0

    The second banner would be displayed OK. The problem was not happening in Safari or Firefox. Trying to fix the problem via CSS didn't help.

    We solved the problem by changing the:

    (adsbygoogle = window.adsbygoogle || []).push({})
    

    to

    $(document).ready(function(){(adsbygoogle = window.adsbygoogle || []).push({})})
    

    jQuery is required for above method.

    0 讨论(0)
  • 2021-01-31 09:26

    I found modifying the ins tag to remove the data-ad-format attribute solved the error for me:

    <ins class="adsbygoogle adslot_1"
     style="display:inline-block;"
     data-ad-client="ca-pub-[MY_AD_ID]"
     data-ad-slot="AD_SLOT_NOS"></ins>
    
    0 讨论(0)
  • 2021-01-31 09:26

    I had the same problem, as there is no sidebar on the homepage and the error only appears on it I corrected by adding this on adsense elements in the sidebar

    cond='data:blog.pageType == "item"'

    0 讨论(0)
  • 2021-01-31 09:30

    I solved it using setTimeout as the issue is that the GA code its not picking the size of the parent on its default loading.

    setTimeout(function(){(adsbygoogle = window.adsbygoogle || []).push({})}, 1000);

    0 讨论(0)
  • 2021-01-31 09:34

    just add style="display:inline-block;width:100%;" this is work for me.

    0 讨论(0)
提交回复
热议问题