How to set up a split tester? need PHP help

4 replies
I'm trying to make a split tester where 50% of my users go to one page, and 50% go to the other.

I'm trying to follow this website:
http://www.richardbonner.net/how-to-spli...ing-pages/

I'm completely clueless in php, but it seems really simple to do.
Lets say I just had a folder for testing purposes and wanted to direct 50% of my traffic to google, and 50% to yahoo

would i just make a index.html and put the following code:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="jquery.js"></script>
<script src="jquery1.js"></script>
<script src="roundabout2.js"></script>
<script src="jqjs.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
<?php
if(rand(0,1) == 0) {
header("Location: http://google.com/');
} else {
header("Location: http://yahoo.com/');
}
?>
</body>
</html>
#php #set #split #tester
  • Profile picture of the author Christopherson
    can anybody help?
    {{ DiscussionBoard.errors[7928031].message }}
  • Profile picture of the author trafficmasters
    Check out google experiments
    {{ DiscussionBoard.errors[7928875].message }}
  • Profile picture of the author Brandon Tanner
    Originally Posted by Christopherson View Post

    would i just make a index.html and put the following code:
    1) You should put your PHP code at the very beginning of that page (above the doctype).

    2) You will need to give that page a PHP extension (ie index.php).

    That said, using 'random' to do split tests is not the most accurate way to go about it, but it should average out to be fairly even over the long run.
    Signature

    {{ DiscussionBoard.errors[7930387].message }}
  • Profile picture of the author Sumit Menon
    Apart from what Brandon said -

    Code:
    <?php
    if(rand(0,1) == 0) {
    header(”Location: http://google.com/');
    } else {
    header(”Location: http://yahoo.com/');
    }
    ?>
    should be -

    Code:
    <?php
    if(rand(0,1) == 0) {
    header('Location: http://google.com/');
    } else {
    header('Location: http://yahoo.com/');
    }
    ?>
    So the quotes match.

    Also, you don't need to import all the javascript and css files if you are going to redirect the page anyway.

    Sumit.
    {{ DiscussionBoard.errors[7930603].message }}

Trending Topics