1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Split testing script?

Discussion in 'CPA' started by muslickzz, Jul 8, 2009.

  1. muslickzz

    muslickzz Junior Member

    Joined:
    May 23, 2008
    Messages:
    109
    Likes Received:
    51
    Gender:
    Male
    Occupation:
    Burden
    Location:
    Up in your Grill...
    Anyone got or know of a decent script or bit of code that will effectively let me split test from a redirect?

    IE: click the link.. get to the page and be redirected on a 50/50 basis to two offers?

    Thanks!
    -Mus
     
  2. mistablackhat00

    mistablackhat00 Regular Member

    Joined:
    May 4, 2009
    Messages:
    308
    Likes Received:
    135
    I understand that this thread is wicked old, but I was about to start one with the same question and figured I would ask here first. Anyone know?
     
  3. Fakker

    Fakker Regular Member

    Joined:
    Dec 22, 2010
    Messages:
    295
    Likes Received:
    38
    Not sure if I get the question, but it seems pretty easy to me.

    Basically you set a variable with a random value between 1 and 2 (each programming language has a command to generate a random number).

    Then use a switch (or a if, given it's just 2 options) to choose where to redirect.
     
  4. idoit

    idoit Registered Member

    Joined:
    Oct 27, 2011
    Messages:
    77
    Likes Received:
    42
    Home Page:
    In plain php english :)

    something like this:

    PHP:
    $urls = array("http://yourUrl/landingpage1.html""http://yourUrl/landingpage2.html");
    header("Location: " $urls[rand(0,count($urls)-1)]);
    This will split test any number of pages uniformly (on a large enough scale). Read more about rand if you want.... Additionally, you can use a DB or a file to write number of visits and then read this number each time you visit the page... something like

    PHP:
    // read the next number
    $number intval(@file_get_contents('file_path')); // write a number to this
    $urls = array("http://yourUrl/landingpage1.html""http://yourUrl/landingpage2.html");
    header("Location: " $urls[$number % (count($urls)-1)]);

    // now write (number+1) to a file
    $fh fopen('file_path''w');
    fwrite($fh, ($number+1));
    fclose($fh);
    I like the first version better, since rand should do the good job... the problem with second one is that I'm not very sure what would happen if you get too much visits to the script - what if it comes to some rewriting and parallel access to your file with number... Database could solve this problem, but I'm too lazy to write this :)
     
    • Thanks Thanks x 1
  5. Fakker

    Fakker Regular Member

    Joined:
    Dec 22, 2010
    Messages:
    295
    Likes Received:
    38
    Much more elegant than the one I would have done.

    Rep given ;)
     
  6. idoit

    idoit Registered Member

    Joined:
    Oct 27, 2011
    Messages:
    77
    Likes Received:
    42
    Home Page:
    Cheers for reps mate.

    This solution evolved through time ;)