Home > General > Affiliate Marketing Forum

php rotation script for 3 landers (6)


07-24-2011 04:40 AM #1 jamesruhles (Member)
php rotation script for 3 landers

quick question!

this is the current code I am using to split test 2 landers

[PHP]<?php
$lp1 = "http://domain1.com?t202id=####&t202kw=" . $_GET['keyword'];
$lp2 = "http://domain2.com?t202id=####&t202kw=" . $_GET['keyword'];

if(rand(0,1) == 0) {
header("Location: $lp1");
} else {
header("Location: $lp2");
}
?>[/PHP]

how can I throw another lander into the rotation?


07-24-2011 06:30 AM #2 pinniped (Member)

Try this:

[PHP]<?php

$links = array(
'http://www.google.com/',
'http://www.yahoo.com/',
'http://www.bing.com/'
);

header('Location: ' . $links[array_rand($links)]);

?>[/PHP]

To add more landers, just add them to the array.


07-24-2011 08:04 PM #3 jamesruhles (Member)

that works, but is ther a way to pass the keyword variable through from the original link like I have in the first part?


07-24-2011 08:40 PM #4 pinniped (Member)

[php]
<?php

$kw = $_GET['keyword'];

$links = array(
"http://www.google.com/?t202id=####&t202kw=$kw",
"http://www.yahoo.com/?t202id=####&t202kw=$kw",
"http://www.bing.com/?t202id=####&t202kw=$kw"
);

header('Location: ' . $links[array_rand($links)]);

?>
[/php]


07-24-2011 10:57 PM #5 liane (Member)

This is one of those over-my-head technical posts I can ignore if I use CPV Lab...right??!?!

;-)


07-24-2011 11:17 PM #6 jroes57 (Member)

Yep cpvLab is awesome for split testing LPs!


Home > General > Affiliate Marketing Forum