How to set up a split tester? need PHP help

by 4 replies
5
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:


#programming #php #set #split #tester
  • can anybody help?
  • Check out google experiments
  • 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.
  • 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.

Next Topics on Trending Feed