XF 1.5 Responsive adsense

upnet

Active member
I am using responsive adsense in ad_message_below and on mobile it works great, but on desktop the ad often covers the post before. Any easy fix for this?

Code:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- responsive header -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="vbnvbnvbnvbnvbn"
     data-ad-slot="nvbnvbnvbnvbnb"
     data-ad-format="auto"></ins>
     
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
 

Attachments

  • adcover.webp
    adcover.webp
    11.7 KB · Views: 11
Ok now I have that code with async responsive adsense unit. Not getting anything displayed though?

Code:
<div style="text-align: center; padding: 8px 0 4px 0; border-bottom: 1px solid @primaryLighterStill">
          <script type="text/javascript">
            google_ad_client = "234234234234";
            width = document.documentElement.clientWidth;
           
            google_ad_slot = "234234234";
            google_ad_width = 300;
            google_ad_height = 250;
               
                    if (width > 743) {
                    /* Thread List Below Stickies */
                    google_ad_slot = "23423423";
                    google_ad_width = 728;
                    google_ad_height = 90;
                    }
            </script>

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">           
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
 
It takes a while for AdSense to start serving ads.
Doesn't specifying width and heights negate the concept of using adsense responsive? It's strange but if I just put their responsive code in the template it works a majority of the time but occasionally it overlaps a post. I asked Google about it and they said it needs to be inside of a <div>. Will it still break out if I just use the div part of the code above and then use the responsive code snip-it without using javascript to determine the browser size?
 
Top Bottom