Simple Split Tester
Split testing is used to find out which of two different web pages gets the better results.
This article shows you how to set up a simple split test. You'll find the code and instructions for using it.
Set up two versions of a web page and put them on your server. Note their URLs because you'll be putting them into the software.
Perhaps you are testing which page gets the most sales or the most subscriptions or the least complaints or the lowest bounce rate.
Prevalent wisdom is to test one thing at a time when split testing. The headline, the type style, the product image, or the background color are examples.
It is unnecessary to be bound by prevalent wisdom. Test two completely different pages if you wish. It's your test, do it the way you prefer.
Now that you have two versions of a web page to test and have the two URLs at hand, you are ready to install the Simple Split Tester software.
Installation consists of copying the PHP code below, updating the code with the two URLs, and putting the code on your website.
Here is the code.
<?php /* Simple Split Tester Version 1.0 December 27, 2010 Will Bontrager https://www.willmaster.com/ Copyright 2010 Bontrager Connection, LLC Bontrager Connection, LLC grants you a royalty free license to use or modify this software provided this notice appears on all copies. This software is provided "AS IS," without a warranty of any kind. */ /* C U S T O M I Z A T I O N */ // Specify the two URLs of the web pages to display. $URL1 = "https://www.willmaster.com/test/pageone.php"; $URL2 = "https://www.willmaster.com/test/pagetwo.php"; /* Customization End */ /********************/ /*******************/ $getURL = (time() % 2) ? $URL1 : $URL2; $url = preg_replace('/^https?:\/\//i','',$getURL); @list($host,$uri) = explode('/',$url,2); $domain = strtolower($host); $uri = "/$uri"; $headsend = "GET $uri HTTP/1.0\r\nHost: $host\r\nAccept: */*\r\n"; if( isset($_SERVER['HTTP_REFERER']) ) { $headsend .= 'Referer: '.$_SERVER['HTTP_REFERER']."\r\n"; } if( isset($_SERVER['HTTP_USER_AGENT']) ) { $headsend .= 'User-Agent: '.$_SERVER['HTTP_USER_AGENT']."\r\n"; } $headsend .= "Connection: Close\r\n\r\n"; $fp = @fsockopen($host,80,$errno,$errstr,20); if( ! $fp ) { echo "Error number: $errno<br />Error string: $errstr<br>Domain: $host<br />URI: $uri"; exit; } $content = ''; fwrite($fp,$headsend); while (!feof($fp)) { $content .= fgets($fp,1024); } fclose($fp); $pos = strpos($content,"\r\n\r\n"); $offset = ($pos>0) ? 4 : 2; $head = substr($content,0,$pos); if( strpos($head,'200 OK') === false ) { echo "Error at URL $getURL<pre>$head</pre>"; exit; } $content = substr($content,$pos+$offset); $base = "<base href=\"$getURL\" />"; $matches=array(); if( preg_match('/<head[^>]*>/',$content,$matches) ) { $content = preg_replace('/(<head[^>]*>)/si',"$1".$base,$content,1); } elseif( preg_match('/<html[^>]*>/',$content,$matches) ) { $content = preg_replace('/(<html[^>]*>)/si',"$1".$base,$content,1); } else { $content = "$base,$content"; } echo $content; exit; ?>
To do the split test, send the traffic to the URL where the above PHP script is installed.
To determine which of the two URLs to display, Simple Split Tester obtains the server system time and divides the seconds number by 2. If there is a division remainder, one of the web pages is displayed. Otherwise, the other is displayed.
To determine the results of your split test, two things need to be known:
-
How many times each of the two web pages were displayed.
A do-your-own page hit counter is at Log File Hit Counter.
-
How many times the desired action was taken at each of the two web pages.
(The desired action is whatever is used to determine which web page is the best. Examples are number of click on a certain link or number of submissions of a certain form.)
Short URL V2 can be used to count clicks. If the number of form submissions needs to be counted, perhaps the software being submitted to can keep a count. Otherwise, a submission relay may be built.
Divide the number of actions into the number of web page displays to get a percentage. (If the web page has 1254 displays and the desired action was taken 172 times, the percentage is obtained with
The web page with the highest percentage wins.
Will Bontrager