SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Nov 2000
    Posts
    741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple Split-Testing script

    I want to create a very simple split-testing script that will alternate between displaying the content from page1.php and page2.php. This content will be shown on index.php.

    If the visitor comes back to that page, it must show the same page they saw before.

    It must track the number of times each page is displayed and the click through rate of each page. This way, I can calculate which page is better for sales.

    Please note that page1.php and page2.php will have php code on them as well as html.

    Thanks,

    Jon

  2. #2
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Did you want to serve each script strictly in rotation, ie 1,2,1,2,1,2,1,2 etc

    Or randomly
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  3. #3
    SitePoint Guru
    Join Date
    Nov 2000
    Posts
    741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Strict rotation is best but randomly is ok if its much simpler. If it is tracking the number of times each page is displayed and the click through rate, then either will do since I can still calculate it. But I prefer strict rotation.

  4. #4
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Database table

    index_t
    Last_sent
    Total_A
    Total_B

    Only needs one record that you update each time the page is served.

    PHP script overview

    read database record
    if Last_Sent = 1 {
    increment Total_B and Last_Sent fields
    execute page_2 script
    }else{
    increment Total_A field
    reset Last_Sent field to 1
    execute page_1 script
    }
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  5. #5
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If the visitor comes back to that page, it must show the same page they saw before.
    Save a cookie (setcookie). So following Mandes' algorithm, you'd also check for the cookie first and then decide whether you need to display the last seen page or a page that comes in the rotation order.
    Saul


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •