1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Responsive ads not working

Discussion in 'Placement / Reviews / Examples' started by jinch, Apr 5, 2015.

  1. #1
    Hello,

    I have a 970x90 ads and I want it to resize to 336x280 when people view it on a low resolution, how cna I do that?

    I tried the @media code explained on Google but it's working. How can I modify my ads to make it resize?

    
    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <style type="text/css">
    .adslot_1 { display:inline-block; width: 336px; height: 280px; }
    @media (min-width:800px) { .adslot_1 { width: 970px; height: 90px; } }
    </style>
    <ins class="adsbygoogle adslot_1"
         style="display:inline-block;"
         data-ad-client="ca-pub-00000000000"
         data-ad-slot="00000000000"
         data-ad-format="horizontal"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>
    Code (markup):

    Best regards,
     
    jinch, Apr 5, 2015 IP
  2. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,198
    Likes Received:
    1,672
    Best Answers:
    29
    Trophy Points:
    475
    #2
    You can try this one. It's a bit different approach, but it works. You can adjust the ad sizes to whatever you want to. Make sure you replace xxxxxxx with your own ca-pub- and ad slot:

    
    
    <div id="google-ads-1"></div>
    <script type="text/javascript">
        ad = document.getElementById('google-ads-1');
        if (ad.getBoundingClientRect().width) {
            adWidth = ad.getBoundingClientRect().width;
        } else {
            adWidth = ad.offsetWidth; // for old IE
        }
        google_ad_client = "ca-pub-xxxxxxxxxxxxxxx";
        google_ad_slot = "xxxxxxxxxxxxx";
        if ( adWidth >= 1200 )
          google_ad_size = ["728", "90"];  /* desktops */
        else if ( adWidth >= 1024 )
          google_ad_size = ["728", "90"];  /* ipads */
        else if ( adWidth >= 640 )
          google_ad_size = ["650", "90"]; /* various tablets */
        else if ( adWidth >= 540 )
          google_ad_size = ["620", "90"]; /* larger cell phones */
        else if ( adWidth >= 200 )
          google_ad_size = ["350", "200"]; /* smaller cell phones */
        else if ( adWidth >= 180 )
          google_ad_size = ["300", "200"]; /* smaller cell phones */
        else
          google_ad_size = ["200", "200"]; /* smaller cell phones */
        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>
    <script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
    </script>
    
    
    Code (markup):
     
    qwikad.com, Apr 21, 2015 IP
  3. GregWR

    GregWR Member

    Messages:
    354
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    43
    #3
    I'm using almost the same code and mine works, it doesn't scale with the website though if you are just testing by resizing your window. If you refresh it'll change to the smaller ad.
     
    GregWR, May 3, 2015 IP
    qwikad.com likes this.
  4. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,198
    Likes Received:
    1,672
    Best Answers:
    29
    Trophy Points:
    475
    #4
    Right, the code isn't fluid and resizes only on refresh.
     
    qwikad.com, May 3, 2015 IP
  5. Saif Rizvi

    Saif Rizvi Member

    Messages:
    143
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    46
    #5
    Sorrry to say but i didnt get the point what exactly you were saying to implement Responsive ads in a website. Can anyone guide me how to implement responsive ads in a website. I tried but it doesnt work. I extract the code and put it in the web but it doesnt shows any ads. Can any one guide me in deep how to implemet responsive ads my website is http://www.wecareplanet.com Please do look and guide me.
     
    Saif Rizvi, May 13, 2015 IP