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.
Your code doesnt work. I have been also looking for a url rotator.
it works now somehow part of the code wasn’t showing in my blog post, try it now. This code DOES WORK now.
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
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);
Outstanding!
With the correction this is exactly what i was looking for.
Thanks so much!
Cheers.
Awesome!
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?
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.
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.
I’ld like to use a rotator for my referal programs but at the bottom of the rotator page, have a text link to my main site. Any idea if this is possible or do url rotators have to use full screen showing the url?
Hi Mike, it has been a couple of months since your post. It seems to be working well (Thanks to the author) after I added the “i”, but would like to see how the full code looks after the other changes you mentioned above. If you could upload that, I would be very thankfull. Thanks.
Hey, does anyone know of a really good WP plugin that is self hosted on your own domain and can set up link rotation to unlimited or high number of URL’s? I want to be able to cloak the links, plus cookie each link so that if that same visitor clicks on that original link again, they will always be taken to the URL they were first directed to. Also with the ability to add weight or percentage to which URL’s get a specific percentage of the clicks. Also with fairly decent tracking statistics so u can see how many clicks each URL has gotten, set up unlimited campaigns etc. I haven’t found a good one yet that can do all these things, any help would be much appreciated, Thanks!
Thank you so much for this.. I’ve been searching for hours for an easy script that worked and this one was the one.. thank you so much!
Hello,
there is a little mistake in the code.
if(!sset($HTTP_cookie_VARS[‘link’])){ $n=count($link);
right is
if(!isset($HTTP_cookie_VARS[‘link’])){ $n=count($link);
the i in !isset was not there.
Greetings Herry
Is there a way to add php code to the script so that we can see a click count to each URL? ie rotator is housed in folder /go/ ie http://www.domainname.com/go/ and stats could be looked at /go/stats/ anyway to add this code and the URL for stats into the script?