Redirecting Help Pls

OnFire25

Junior Member
Joined
Mar 24, 2008
Messages
115
Reaction score
261
For split testing is it possible to create a page that will randomly select one page to display to a visitor.

Nothing blackhat here I know but I have an idea based on c0nversi0nPr0fit that I haven't seen anywhere else.

As c0nversi0nPr0fit only allows tracking of 3 versions of a landing page I am trying to create an index.php that will randomly select from index1.html, index2.html and index3.html.

I have used the following code :

Code:
<?php
 $pageid =  rand(1, 3);
 if ($pageid == 1){$location = "http://www.google.com";}
 else if ($pageid == 2){$location = "http://www.yahoo.com";}
 else if ($pageid == 3){$location = "http://www.msn.com";}
 echo "<a href=$location>$location</a>";
?>

and this echo does display a random pagelink in text but I can not work out how to get it to open the selected/displayed location.

As you can guess I am not a php coder

So happy for any workable suggestions


Thanx
 
There is. I read about how to do that in the Beating Adwords book but can not remember how
 
Here you go

Code:
<?php
 $pageid =  rand(1, 3);
 if ($pageid == 1){$location = "http://www.google.com";}
 else if ($pageid == 2){$location = "http://www.yahoo.com";}
 else if ($pageid == 3){$location = "http://www.msn.com";}
 echo "<meta http-equiv="refresh" content="0;url=$location">";
?>
 
Hi Bozo,

Thanks for the code - slight problem when I upload this to my host using PHP version 5.2.6 I get the following error

Code:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/xxxxxxxxxxx/public_html/xxxxxxxxxxx/index.php on line 6

Any thoughts on this ?


Thanx
 
Last edited:
Oops I forgot to escape the quotations
Code:
<?php
 $pageid =  rand(1, 3);
 if ($pageid == 1){$location = "http://www.google.com";}
 else if ($pageid == 2){$location = "http://www.yahoo.com";}
 else if ($pageid == 3){$location = "http://www.msn.com";}
 echo "<meta http-equiv=\"refresh\" content=\"0;url=$location\">";
?>
That should work.
 
Thanx

that works.

Now all I need to get working is some javascript in this to get the split testing results.

the code is
<script language="javascript" src="http://www.xxxxxxxxxx.com/tracker.php?uid=9&cid=12"></script> which is supposed to track visitors is there any special codes that are needed because I have tried this and the mysql is not being updated so I guess that how I have entered the code is wrong

Truely grateful for the support and help
 
Make sure you have set up the database right and are actually updating it with php. mysql usually displays errors when you have a problem. You have to write the code that updates it on every visit or make user the script is doing that for you.
 
lol that's a really messy way to do something simple...
What happens if you want to add more sites? More variables and elsfis? :(
Code:
<?php
$redirects = array(
        "http://www.site1.com",
        "http://www.site2.com",
        "http://www.site3.com",
        "http://www.site4.com",
        "http://www.site5.com"
);

header("Location: " . $redirects[mt_rand()%count($redirects)] ."");
?>
 
Last edited:
Hi bhnoobz

Purrrrrrrrfect thanx for K I S S ing it for a non coder.

Have you any suggestions about getting the javascript into the php code have been tryng but it is not updating the mhsql database so I have f***ked it up somewhere.

What I am doing is taking a ppc tool and attempting to reuse it as a split testing tool - I do like to look outside the box.

Appreciate your time and suggestions
 
Back
Top