Multivariate A/B testing for PHP

Multivariate A/B testing for PHP

Released 4 years ago , Last update 5 months ago

A/B testing interface / library for fast A/B tests integration into any PHP based code and results review. Already used on a Millions of tests.

Benefits

  • Time-Saving

    Focus on the product, rather than technical setup.

    Setting up A/B tests on your unique project can be time consuming and painful process. You always need to track impressions, decide which variant to show by various algorithms, track conversions and analyze them.

  • Act fast

    Dedicated interface to show how your tests are performing.

    Mobile friendly interface will allow you to fully customize each test and see its results in organized way with graphics. Implement, measure and decide fast.

  • Extensible

    Supports custom algorithms and test rules. Documented and well readable.

    Add another custom algorithm besides already implemented 50/50, Multi Armed Bandint and Multi Armed Bandint UCB1. Make the test behave like you want. "Custom algorithms" section below.

Use Case

Perfect example of it can be banner, subscribe buttons clicks, testing headline or button color, all the things that could be covered by abtests. It also provides PHP library which chooses next testing variant by several algorithms and do all the backend work with single method call. All the interface is completely separated from your project and interacts via very simple API.

AB testing Kit features

  • All the backend tracking hard work;
  • Interface to monitor how your tests are going;
  • Interface is completely separated from your main project;
  • Design based on bootstrap3 responsive design so it will look good on tablet and smartphone too;
  • Supports 50/50, Multi Armed Bandint and Multi Armed Bandint UCB1 algorithms;
  • Easy to add custom algorithms, you can contact me for any help or look "Custom algorithms" section below;
  • All of the tests have auto-generated proof of concept examples of how to integrate them;
  • Limit individual test execution by conversions or impressions count;
  • Set start and end dates of test;
  • Fill all of the test inputs to have nice abtesting history of your project;
  • Supports MySQL, PgSQL, SQLite (via PDO);
  • Supports older PHP versions (PHP>=5.1.3) and newest PHP7 too;
  • Tested and working on apache and nginx;
  • Very easy to translate/localize to your native language by changing only 1 file;
  • Open sourced MVC PHP framework;
  • Both framework and app have unit tests;

Requirements

  • PHP >= 5.1.3;
  • PHP PDO with one of MySQL, PgSQL, SQLite for storing all the data;
  • Apache mod rewrite or corresponding nginx rules setup;
  • Optional memcached for session handling;

Pricing

7 day 7-day money-back guarantee

$24.99

Hosted License

  • Perpetual license

  • 1 site, unlimited servers

  • No distribution (hosted use only)

  • Commercial use

$499.99

Developer License

  • Perpetual license

  • Unlimited projects

  • Can distribute code and binary products

  • Commercial use

  • 6 months support

Need custom services for this product? Get a quote

Documentation

  • All the interface code is located in app/ directory;
  • Change all the custom settings in app/config.php file;
  • Translate/localize in app/translations/ directory;
  • Shared library for your project is located in libs/abtesting.php file. Mainly you want to use just two methods, test() and inc()

abtesting::test()

<?php
/**         
 * Main method to call when need to select test result
 * This sets cookie so must be called before any output!
 * $test = abtesting::test ( 'color_test', array ( 'red', 'green', 'blue' ) );                                                                                                                   
 * <a href="somewhere.php?__ab=<?= $test [ 'token' ]; ?>" style="color:<?= $test [ 'value' ]; ?>">link</a>
 * @param string $name - test code name
 * @param array $variants - array of possible variants
 * @param string $test_type - whenever to use 'mab', 'ucb1' or '50/50'
 * @param boolean $return_false_instead_of_best_variant - whenever to return false or current best variant
 return array - token to be passed and selected value
*/     
public static function test ( $name, $variants, $test_type = '50/50', $return_false_instead_of_best_variant = false )

abtesting::inc()

<?php
/**
 * Method to call when action is performed
 * abtesting::inc ( $token );
 *
 * @param string $token - token passed from test
 *
 * return boolean
 */
public static function inc ( $code )

Setup / installation

Installation is performed by these steps:

  • Download code in "abtesting" or whatever you want directory (as long as it is somewhere in document root);
  • If your directory name is not "abtesting" then modify .htaccess and app/routes.php files to specify base_path;
  • If you're using nginx take a look at nginx.conf;
  • Edit app/config.php file and change interface login credentials. User password must be placed as md5 hash. By default user is "administrator" and password is "ab42test";
  • Edit app/config.php and edit database config. There are examples of them for MySQL, PgSQL and SQLite;
  • If you don't have memcached support then comment/remove session_handler config from app/config.php to have php default session handling;
  • Go to yoursite.com/abtesting (or the directory you've named) and you should see login screen. Use your changed credentials;
  • If you've specified database settings correctly you will see "click to install" link. After clicking it database tables will be installed as long with some example data;

From there you have 2 ways to setup your first abtest, either by first setting up the code, either first setting up via admin interface and then code. Lets say you're doing some wording test and want to see which of the following phrases ("Free beer", "Click now", "Must have") perform best on your banners:

<?php   
// Include independent abtesting library
require 'abtesting/libs/abtesting.php';

// If there are performed some conversion/action
if ( isset ( $_GET [ 'action' ] ) )
{
    // If that action is performed via valid abtest
    if ( isset ( $_GET [ '__ab' ] ) && !empty ( $_GET [ '__ab' ] ) )
    {
        // This abtest conversion is accepted
        if ( abtesting::inc ( $_GET [ '__ab' ] ) )
        {
            // Do something if you want
        }

        // Duplicate conversion detected. Ignoring.
        else
        {
            // Do something if you want
        }
    }
    // You're already tested. Ignoring.
    else
    {
         // Do something if you want
    }
}
else
{
// Performing the test with 3 options, all have random possibility to show $test = abtesting::test('banner_wording', array('free_beer', 'click_now', 'must_have'), '50/50'); } ?>

Then in your template do the following proof of concept:

<?php
// If the test was performed if ( isset ( $test ) ){
// The __ab = token hold all the magic echo '<a href="?action=1&__ab='. $test [ 'token' ] .'">';
// The value is one of the options you've specified in the last snippet if ( $test [ 'value' ] == 'click_now' ) { echo 'Click now'; } elseif ( $test [ 'value' ] == 'must_have' ) { echo 'Must have'; } else { echo 'Free beer'; } echo '</a>'; } ?>

After first impression of this test database will be updated and you will be able to see it from interface. Also if you'll fill control impressions and control conversions statistical significance will be calculated for you. There are 2 optional arguments for abtesting::test method:

$test_type - It can be either '50/50', 'mab' or 'ucb1' for multi armed bandit ucb1 testing approach;
$return_false_instead_of_best_variant - if it is true then if something is wrong with test or it is expired then false is returned instead of best variant;

Example usage

Proof of concept banner position test

<?php
$test = abtesting::test('banner_position', array('left', 'right'));
echo '<a href="?action=1&__ab='.$test['token'].'" class="banner_'.$test['value'].'">Click me</a>';
?>

Custom algorithms

Adding custom algorihtms is extremely easy. Open libs/abtesting.php file and modify "test" method. Around line ~200 add similar lines:

// Custom test to choose variant with biggest conversions 9 times out of 10
elseif ( $test_type == 'my-custom-test' )
{
    // Lets experiment 1 time out of 10
    if (mt_rand(1, 10) === 10) {
        $index = array_rand($variants);
    } else {
        $biggest_conversion = -1;

        // Iterate over all variants
        foreach ( $variants as $i => $variant )
        {
            if ( isset ( $stats [ 'variants' ] [ $variant ] ) )
            {
                // Select variant with the biggest conversion
                if ( $biggest_conversion < $stats [ 'variants' ] [ $variant ] [ 'conversions' ] )
                {
                    $biggest_conversion = $stats [ 'variants' ] [ $variant ] [ 'conversions' ];
                    $index = $i;
                }
            }
        }
    }
}

Then simply execute the test:

<?php
$test = abtesting::test('my-custom-test', array('left', 'right'));
echo '<a href="?action=1&__ab='.$test['token'].'" class="banner_'.$test['value'].'">Click me</a>'; ?>

And that's it, your test will be focused on the best performing variant!

Why are you still waiting?

Try it now with 7 days money back quarantee. There are no excuses.

3 licenses, starting from From » $24.99 View Licenses

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.

or Get a quote

for customization or integration services


Or enter your name and Email
  • KB Karim Ben License holderDeveloper License
    6 month support
    Purchased on Aug 30, 2015
    2 years ago
    Do it do a 50/50 split? Can it be used for a complete page. 2 totally different pages?
    • Arminas Zukauskas Publisher 2 years ago
      Hello, It supports 50/50, Multi Armed Bandint and Multi Armed Bandint UCB1 algorithms. Hosted License is for 1 project while Developer License is for unlimited number of projects. So if your 2 different pages are on the same domain/website you can use it with Hosted without any problems. Otherwise please consider purchasing Developer License.
    • KB Karim Ben 2 years ago
      Thanks for the answer. Do you have any demo account we can have a look? Is the developer License a hosted solution only?
    • Arminas Zukauskas Publisher 2 years ago
      Hello, You can look for live interface on http://ini.lt/abtesting/login login user "demo", password "demo". You will need to host your files with all the licenses on your own server. It is not standalone service (saas) but more like software you purchase. You will need hosting with PHP>=5.1.3 support and either of MySQL, PgSQL, SQLite, no any other requirements. There is installation instructions and you can contact me in case of any problems during setup. "Developer License" would allow you to do whatever you want with received code while "Hosted License" allows use it on a single project without any further rights to publish or re-use on others.