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?
January 17th, 2012 at 2:54 am
http://www.mooonbaby.com/scripts/absolutecookierotators.html
I have been working on this script for over 24 hours now and allthough it does seem to function as a random rotator and it sets cookies ok it does not seem to return to the original page after cookies have been set so I was looking around for paid for cookie rotators and found some funnily enough on this same site moonbaby so I thought in return for the free oportunity that the last day has given me to improve my php skills I would return the link above.
January 17th, 2012 at 11:48 am
Got it working at last! Been working on it a few days now. Whoever wrote is is basically very gifted. But there were two other typos besides the isset that was mentioned. First the opening and closing php tags ( if you bother using the closing tag which not everyone does apparently ) need to go on their own seperate lines. And secondly the single quotation marks around the COOKIE object need replacing with double quotation marks and the original $HTTP_COOKIE_VARS function just after the original isset function needs replacing with a simple $COOKIE function and then it seems to all work just fine. My professional compliments to the author of the original draft and my sincere thanks for making the code publicly available.