go top

Banner and link rotation

I have many web sites and on most of them I run all kind of link/banner exchange or affiliate programs. Some of the affiliate programs perform much better and others are not that good. However, you will need a lot of time to find out which one perform better than the others. You will have to put a banner for the 1st affiliate program for few days and analyze its performance results. Then you will have to do the same for the other affiliate banners and at the end to choose the best one. Of course if you have 5 different banners you will need to spend 5 x 3 days each = 15 days to find out which one is the best.

What I would suggest is to randomly show all the banners during the first 3 days. At the end you will have the impressions, clicks, sales results for all of the banners and you can decide which one to use a lot sooner.

Now, what I am going to do is define PHP array with all the 5 affiliate codes. Then using the PHP rand(min,max) function I will randomly select one of these 5 array elements. The first parameter defines the minimum value that you want and the second parameter is for the maximum value that you want generated. In our case we need to use rand(1,5). All that has to be done now is to print the randomly selected array element.

<?php
$mybanners[1] = '<a href="http://www.affiliate1.com"><img src="banner1.jpg"></a>';
$mybanners[2] = '<a href="http://www.affiliate1.com"><img src="banner1.jpg"></a>';
$mybanners[3] = '<a href="http://www.affiliate1.com"><img src="banner1.jpg"></a>';
$mybanners[4] = '<a href="http://www.affiliate1.com"><img src="banner1.jpg"></a>';
$mybanners[5] = '<a href="http://www.affiliate1.com"><img src="banner1.jpg"></a>';

$id = rand(1,5);

echo $mybanners[$id];
?>

8 Comments to "Banner and link rotation"

Add your comment

Captcha
    • Free Scripts

      Add great new functionalities to your website with our Free Scripts collection.

      Free scripts
    • PHP Scripts

      Check our extensive collection of top-notch PHP Scripts that will enhance your website!

      Commercial PHP scripts