Randomly rotating Adsense ads

Discussion in 'Guidelines / Compliance' started by gradient, Oct 16, 2010.

  1. #1
    I figured you could insert some Javascript of your own into the code Google gives you to randomly display different ads instead of the same one all the time but apparently messing with the code they give you is against Adsense terms of use.

    But is it ok to randomly switch out the code block itself? What if you used another language like PHP to display at random times one code block and then another? You wouldn't be changing the code Google gives you at all.
     
    gradient, Oct 16, 2010 IP
  2. vitalbusiness

    vitalbusiness Peon

    Messages:
    882
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can rotate ads. Shouldn't be a problem. I used to have a site where sometimes I rotated a 728X90 and 468X60 ads.

    I used this ad rotator (you can add as many ads as you want: $bannerAd[3] $bannerAd[4], etc.):

    <?php
    $bannerAd[1] = 'code for ad 1';
    $bannerAd[2] = 'code for ad 2';

    $adCount = count($bannerAd);
    $randomAdNumber = mt_rand(1, $adCount);
    echo $bannerAd[$randomAdNumber];
    ?>
     
    vitalbusiness, Oct 16, 2010 IP
  3. vitalbusiness

    vitalbusiness Peon

    Messages:
    882
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    By the way this code will rotate anything: banner ads, text ads, quotes, photos, etc.
     
    vitalbusiness, Oct 16, 2010 IP
  4. JamesColin

    JamesColin Prominent Member

    Messages:
    7,874
    Likes Received:
    164
    Best Answers:
    1
    Trophy Points:
    395
    Digital Goods:
    1
    #4
    Hi, your code can be simplified to:

    <?php
    $bannerAd[] = 'code for ad 1';
    $bannerAd[] = 'code for ad 2';

    shuffle($bannerAd);
    echo $bannerAd[0];
    ?>

    Yes shuffle() randomizes the array.
     
    JamesColin, Oct 17, 2010 IP
  5. vitalbusiness

    vitalbusiness Peon

    Messages:
    882
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    That's really cool! Thanks!
     
    vitalbusiness, Oct 17, 2010 IP
  6. mich.ewriter

    mich.ewriter Member

    Messages:
    151
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #6
    I just learn this now. Thank you for the contribution
     
    mich.ewriter, Oct 17, 2010 IP
  7. wptheme

    wptheme Well-Known Member

    Messages:
    4,051
    Likes Received:
    346
    Best Answers:
    0
    Trophy Points:
    180
    #7
    Besides randoming the ads, would it be ok to make the ads popout?
     
    wptheme, Oct 17, 2010 IP