homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Google / Google AdSense
Forum Library, Charter, Moderators: incrediBILL & jatar k & martinibuster

Google AdSense Forum

Script to automatically change adsense on a site?
Script to automatically change adsense on a site?

 1:49 am on Feb 12, 2010 (gmt 0)

as a webmaster who uses adsense is there some script which i could use to automatically change adsense on a site or make one advert with one theme appearing one time, and another advert based on a different colour themes appearing next?

this would allow:

- me to use different banners on same banner space
- allow me to easily change adsense banners in future



 2:07 am on Feb 12, 2010 (gmt 0)


It is kind of the thing you want.


 2:28 am on Feb 12, 2010 (gmt 0)

I've got a PHP script I use, if you can use PHP.


 3:47 am on Feb 12, 2010 (gmt 0)

hi netmeg - thank you how do i get hold of that?

[edited by: incrediBILL at 4:53 am (utc) on Feb 12, 2010]
[edit reason] no email addresses please [/edit]


 3:03 pm on Feb 12, 2010 (gmt 0)

The way I do it - I put each bit of AdSense code in a separate file - red.php, blue.php and green.php (if I want to rotate the colors, for example) and I stick them in a directory called ads.

The I make a script like this:

$x = rand(1,3);
switch($x) {

case 1:
include $_SERVER['DOCUMENT_ROOT']."/ads/blue.php";

case 2:
include $_SERVER['DOCUMENT_ROOT']."/ads/red.php";

case 3:
include $_SERVER['DOCUMENT_ROOT']."/ads/green.php";


And I name the script, say, random468.php (so I can tell what type of ads are in there)

Then I include it in the page in the spot I want the ads to show:

<? include $_SERVER['DOCUMENT_ROOT']."/random468.php" ?>

And the ads will rotate evenly. If I decide I don't like blue one, I change the one line to be $x = rand(2,3); so it will just rotate between red and green.

Adapt to suit.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Google / Google AdSense
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved