1

Install the latest version of phpA/B

  1. Download the latest version of phpA/B.
  2. Unzip phpab.zip.
  3. Upload phpab.php anywhere on your web server.
  4. Include phpab.php at the top of your PHP page.

    <?php
    require_once('/path/to/phpab.php'); // include phpab.php
    
2

Add variations to web pages

  1. Setup the variation at the top of your PHP page.

    <?php
    $my_test = new phpab('my_test'); // set the name of the a/b test
    $my_test->add_variation('my_variation', '<p>My alternative content</p>'); // add a variation
    
  2. Wrap control content in {phpab} tags to run HTML variations. Whatever is inside {phpab} tags will be replaced with a variation or left alone if the user is in the control group.

    {phpab my_test}<p>My control content</p>{/phpab my_test} 
    
  3. Add CSS variations. phpA/B will automatically add the name of the current variation as a class name to the <body> tag.

    p
    {
      color: black; /* control styles */
    }
    
    .phpab-my_variation p
    {
      color: red; /* variation styles */
    }
    
3

Track results in Google Analytics

phpA/B should automatically detect your Google Analytics tracking code and add the necessary lines of code. Give Google Analytics a few days to begin showing the results of your A/B tests.

Screenshot of Google Analytics tracking with phpA/B

  1. Open Google Analytics to the website running phpA/B.
  2. In the left menu, go to Visitors » Custom Variables.
  3. In the main content, you should see a list of the tests you're running. Drill down on a test by clicking it.
  4. The main content will list usage statistics on each of your variations.

For more advanced segments reporting based on your variations, read this article.

Looking for a hosted A/B testing service? Try Visual Website Optimizer free for 30 days