1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 Adsense Javascript

Discussion in 'Styling and Customization Questions' started by upnet, Oct 12, 2016.

  1. upnet

    upnet Active Member

    Is it redundant to have this same code in three different ad templates?

    I find even though I am calling the same ad unit I still see the same ads on page frequently.

    <div id="google-ads-1"></div>

    <script type="text/javascript">

    /* Calculate the width of available ad space */
    ad = document.getElementById('google-ads-1');

    if (ad.getBoundingClientRect().width) {
    adWidth = ad.getBoundingClientRect().width;
    } else {
    adWidth = ad.offsetWidth;
    }


    google_ad_client = "ca-pub-812581712xxxxxxxx";


    google_ad_slot = "191731xxxxxxxx";

    if ( adWidth >= 728 )
    google_ad_size = ["728", "90"];

    else
    google_ad_size = ["300", "250"];

    document.write (
    '<ins class="adsbygoogle" style="display:inline-block;width:'
    + google_ad_size[0] + 'px;height:'
    + google_ad_size[1] + 'px" data-ad-client="'
    + google_ad_client + '" data-ad-slot="'
    + google_ad_slot + '"></ins>'
    );

    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
     

Share This Page