I was searching for a free PHP url rotator this morning, and found the perfect php script . Note: this post is for people who do affiliate marketing others will fall asleep in reading the next paragraph. Ok, If you want to split test different affiliate offers, this is the easiest way to test more than one offer to see which one performs better. I def don't split test enough, I get lazy and complacent but I am going to be changing that with the use of this script. This is nothing new but now I have a script ready to go anytime I want it.
All you need to do is create an index.php file with just the php url rotator script below. You can easily create this in notepad and simply save it as index.php – then simply upload to the domain or folder where your ad is pointing. (The example below shows a split test of 3 links, but you can add/remove them as needed). I wanted something super simple and easy for me to update and this is it:
Free PHP url rotator:
<?php $link[1] = "http://yourdomain.com/index1.html";
$link[2] = "http://yourdomain.com/index2.html";
$link[3] = "http://yourdomain.com/index3.html";
if(!sset($HTTP_cookie_VARS['link'])){ $n=count($link);
$rand=rand(1,$n); setcookie("link",$rand,time()+3600);
header('location:'.$link[$rand]); }else{ $go=$link[$_COOKIE['link']]; header('location:'.$go); } ?>
PS: So much for blogging every 3rd day lol. This is kind of important though, for affiliate marketers anyways.
August 18th, 2010 at 8:26 pm
Your code doesnt work. I have been also looking for a url rotator.
August 19th, 2010 at 6:51 am
it works now somehow part of the code wasn’t showing in my blog post, try it now. This code DOES WORK now.
September 28th, 2010 at 9:28 pm
I’m trying to use your script and I keep getting this error:
Fatal error: Call to undefined function sset() in servername/index.php on line 4
Do you know what it could be? And if so…is there anyway you could explain it for the average web user?
Thanks!
Yemi Ogunbase
December 6th, 2010 at 5:20 pm
Yemi, it’s just a typo, change sset() to isset()
Or full corrected line 4 here:
if(!isset($HTTP_cookie_VARS['link'])){ $n=count($link);
December 15th, 2010 at 12:18 pm
Outstanding!
With the correction this is exactly what i was looking for.
Thanks so much!
Cheers.
December 19th, 2010 at 3:57 pm
Awesome!
August 18th, 2011 at 8:43 am
Nice piece of code, thank you. I’ve been looking for something like this. Any hints on how to make it redirect a certain percentage of the site traffic?