If you do any sort of landing page testing, you know the value of a good splitter. Here is mine. With it you can get even rotation regardless of the number of pages you want to split. Just change a couple of items, and have at it.
If you want to rotate a lot of things, then you're better off re-writing this to use an array and loop it.
But for 2 - 4 pages, this is pretty idiot proof.
For an A / B split:
For A / B / C split
You may notice that the else statement in these examples only decreases the count and doesn't redirect. That is because I usually put this on one of the pages I am testing (above the HTML). If you want to put this script on a splitter page (ie. split.php), then simply add a redirect to the else statement, like this:
Also, since the php header redirect is not relative, you can also test between domains.
Enjoy!
If you want to rotate a lot of things, then you're better off re-writing this to use an array and loop it.
But for 2 - 4 pages, this is pretty idiot proof.
For an A / B split:
Code:
$file = 'count.txt'; // file where the number is stored
$num = file_get_contents($file); // variable to store number from file
if ($num == 1) {
header( 'Location: http://website1.com/lp1.php?'.$_SERVER['QUERY_STRING'] ) ;
$num++; // increment number by one
} else {
$num = $num-1; // decrease number by number of tests minus 1. Ex: 3 tests = decrease by 2
}
file_put_contents($file, $num); // write new number to file
Code:
$file = 'count.txt'; // file where the number is stored
$num = file_get_contents($file); // variable to store number from file
if ($num == 1) {
header( 'Location: http://website1.com/lp1.php?'.$_SERVER['QUERY_STRING'] ) ;
$num++; // increment number by one
} elseif ($num == 2) {
header( 'Location: http://website1.com/lp2.php?'.$_SERVER['QUERY_STRING'] ) ;
$num++; // increment number by one
} else {
$num = $num-2; // decrease number by number of tests minus 1. Ex: 3 tests = decrease by 2
}
file_put_contents($file, $num); // write new number to file
Code:
$file = 'count.txt'; // file where the number is stored
$num = file_get_contents($file); // variable to store number from file
if ($num == 1) {
header( 'Location: http://website1.com/lp1.php?'.$_SERVER['QUERY_STRING'] ) ;
$num++; // increment number by one
} elseif ($num == 2) {
header( 'Location: http://website1.com/lp2.php?'.$_SERVER['QUERY_STRING'] ) ;
$num++; // increment number by one
} else {
header( 'Location: http://website1.com/lp3.php?'.$_SERVER['QUERY_STRING'] ) ;
$num = $num-2; // decrease number by number of tests minus 1. Ex: 3 tests = decrease by 2
}
file_put_contents($file, $num); // write new number to file
Enjoy!