Landing Page – Split-testing – PHP Script

This is just going to be a quick post.

PPC advertising is very helpful when optimizing for maximum conversion rates.  In SEO, you don’t pay for each visitor, so the focus is generally on trying to get the visitor, but the most importantly you need to maximize sales and conversions.

First split testing script

So, here is the first PHP script for split testing.

Then make at least two different versions of the page you are going to target, and call each page landingpage1.php, landingpage2, etc.

For example (for split testing five landing pages), edit the top of the script to:

$landingpage[1] = 'landingpage1.php';
$landingpage[2] = 'landingpage2.php';
$landingpage[3] = 'landingpage3.php';
$landingpage[4] = 'landingpage4.php';
[5] = 'landingpage5.php';

This will automatically show each page an equal amount of times.  In this example, all of the pages would each be shown forcefully 20% of the time.

Second split testing script

This script is more efficient from the server’s point of view:

$landingpages = array(





header(‘Location: ‘ . array_rand($landingpages));

The above code just has one downside.  All of the above pages may not be shown an equal amount of times.  It’s almost equivalent to tossing a coin 100 times.  Statistically it should land on “heads” 50 times and “tails” 50 times, but in reality it won’t.

I’d personally pick the first method.

Share this:




Leave a Reply

Your email address will not be published. Required fields are marked *