Adsense Rotate Formula

(Visited 1075 times)

If you are using Wordpress you could use my Wordpress plugin Adsense-Paster to rotate any numbers of ad units, if not, you could use this simple script.


<!–p $random_number=rand(1,3);<br–>if ($random_number==1){
?>
//adsense format 1

<!–p<br–>} else if ($random_number==2){
?>
//adsense format 2

<!–p<br–>} else if ($random_number==3){
?>
//adsense format 3

<!–p<br–>}
?>

What the code will do is, when the page is accessed, the code will pull a random number from 1 to 3, then display the appropriate adsense code. It will only shows one ad unit at a time.

If you want to have more choices of ad unit format, just increase the max number (currently is 3), and add more adsense code segment, like this:

<!–p $random_number=rand(1,5);<br–>if ($random_number==1){
?>
//adsense format 1

<!–p<br–>} else if ($random_number==2){
?>
//adsense format 2

<!–p<br–>} else if ($random_number==3){
?>
//adsense format 3

<!–p<br–>} else if ($random_number==4){
?>
//adsense format 4

<!–p<br–>} else if ($random_number==5){
?>
//adsense format 5

<!–p<br–>}
?>

Category: Adsense

Leave a Reply

You must be logged in to post a comment.