WordPress A/B, Split Testing with Theme Switching

Recently I’ve been looking for effective ways of performing A/B or Split testing on WordPress powered websites. I have come up with several approaches, the first of which utilizes theme switching to effectively segment users according to assigned percentages and then show them an assigned theme. To maintain consistency, the prescribed theme is stored in a cookie so that the user is always shown the same experience upon returning. Lastly, some user-defined JavaScript is appended to the page with the theme name substituted in to support tracking via services such as Google Analytics or Omniture.

Installation is standard, just activate the plugin. A new option will appear on the Settings section called Split Testing that allows you to configure which themes to use, what percentage of traffic to place into each theme and what JavaScript to append. After setting up your options, go ahead and save the form and you’re all set. With that, simply make sure to add a call to wp_footer() in each of your themes so that the tracking code can be output. You can also manually force a theme by specifying its name with the ‘force_theme’ parameter in the URL like so “http://www.example.com?force_theme=namehere

Some example tracking code for Google Analytics:

try {
     _gaq.push(["_setVar", "[themename]"]);
}
catch(err) {}

try {
     pageTracker._setVar("[themename]");
}
catch (err2) {}

The admin interface was inspired by the original spit testing plugin which I had looked at, but it seems that it has been broken for some time, which is what inspired me to build this one.

As far as I know this works up to WP3, although it won’t be effective with caching solutions that stop plugins from running. For that reason, I’m continuing to implement other solutions that work with caching.

Download here.

Leave a Reply