Your WordPress E-Commerce A/B Testing Start-up Guide

Written by Tom Ewer on May 27, 2014 Blog.

A/B TestingI’ve already talked about A/B testing plugins for WordPress that make setting up split tests a snap. But what I didn’t go into much detail about is how to actually get started with A/B testing. How does it work? How do you run a test?

As you might’ve guessed, this information is vital for the overall success of your e-commerce store, so let’s spend some time today going over the details.

How A/B Testing Works

A/B testing – or split testing as it’s often called – involves using two different versions of various parts of your website, placing them under a magnifying glass, and evaluating which version is the most successful at bringing in conversions. These aspects of your site could be a bit of copy, the design of a lead generation form, the photos featured, or a multitude of other things.

Some businesses treat A/B testing as optional and that’s just something I don’t understand. If you want to make sure your store is performing as good as it possibly can, split tests give you concrete evidence of what’s working and what’s not. That way, you can make changes and optimize your online store to the best of your ability.

A Simple Startup Guide

To get started with A/B testing, you can use one of several plugins I mentioned in my previous post, or you can skip the potential site lag issues and just use Google Content Experiments. Now, this used to be a separate tool called Website Optimizer but it has since been rolled into the robust tool that is Google Analytics. It does work a bit differently than what you might expect. For instance, Content Experiments allows you to set up five different versions of a page, each of which is shown to visitors on a separate URL.

Let’s say you want to set up a test on your home page. You’d create five different versions of this page and when a visitor goes to your site, Content Experiments would load a version at random. This way, you get a fair assessment of how each version performs.

Content Experiments Metrics

I highly recommend you review the support documentation for Content Experiments provided by Google to get a sense of the full setup process. Even so, I’m going to review the basics here.

Using Content Experiments with WordPress

One of the biggest problems with using Content Experiments with WordPress has to do with where you need to place a bit of javascript. As with all Google tracking products, you need to insert some code onto your site in order for the experiments to work. However, you’re supposed to insert this code in the <head> tag, and in WordPress, the <head> that’s served up for every page is created within header.php. As Stu Miller points out, if you were to insert this code in the <head> it would end up on every page of your site, which would cause it to break. You definitely don’t want that to happen!

But there is a fairly easy fix. It does involve diving into the code a bit but if you want to use A/B testing regularly, it’s going to be well worth the time investment. So, once you’re logged into your WordPress site, open up the original version of the page you want to test. In the URL bar, you should see the post ID. It’ll appear after “post.php?” in the URL as “post=ID” with “ID” being a number. Jot down that number.

Next, download your header.php file. You’ll also want to create a backup of your site at this point. Any time you’re messing with the main theme files, you need to be careful. With header.php open on your desktop in a code editor of your choice, scroll to just below <head> and insert the following bit of code courtesy Stu Miller:

<?php if (is_page(***PAGE ID***) ):?>


<?php endif; ?>

Where it says ***PAGEID*** you should insert the number you wrote down earlier. And where it says ***GOOGLECODE*** you should copy and past the javascript code output by Content Experiments. Note: You also need to include the standard Google Analytics code on your site for your experiments to track properly. 

That’s all there is to it. This little bit of code basically states that the bit of javascript should only work on pages that contain the page ID you identified. No need to break your site to run an effective A/B test on WordPress! Save your edits and upload the new version of header.php to your site. That’s why you made the backup earlier – it’s better to be safe than sorry!

From there, you can use the Google Analytics dashboard to set up your actual experiments and track their progress. You can configure all sorts of settings including the length of the experiment, the number of pages to be tested, and more.

If you were feeling a bit discouraged by the prospect of having to do some intensive coding, I hope those fears are now waylaid. Just a little cut and paste ought to do the trick.

Using A/B Testing Plugins

As I mentioned earlier, there are several plugins out there that make it possible to set up and track A/B tests. The four I mentioned in my previous post are all good candidates if you wish to take this approach. Just to refresh your memory, those plugins were Nelio A/B Testing, Marketing Optimizer for WordPress, Convert Experiments by Yoast, and WordPress Calls to Action.

Of course, there are other options out there, too. Let’s take a quick look at two more plugins.

WordPress Landing Pages

If you want to run landing page split tests, there’s WordPress Landing Pages. This plugin makes it easy to set customized landing page templates, run split tests, and monitor your progress.

And there’s Optimizely, which lets you manage your account within the WordPress dashboard. It promises to be an easier way to manage A/B tests.

Of course, a good bit of trial and error is to be expected here. That’s the nature of split tests and why it’s so important to take the time to do them. Without the information you gather from A/B tests, you won’t know how your site is performing. Period.


There are several ways to conduct A/B tests for websites and to optimize for conversion. But since WordPress is a unique platform, you need to make sure you’re bringing the right tools for the job on board. The Content Experiments tool within Google Analytics is a robust solution – not to mention a free one. And all it takes is a little custom code snippet to get it up and running.

If you’d rather go a more automated approach or don’t use Google Analytics, a plugin may be more suited to your needs. At the end of the day, it comes down to what kind of experience you want as a site admin. What features are necessary for you? Do you want to manage your A/B tests within the dashboard or is that something that doesn’t matter to you? It’s a lot to think about, but definitely worth the investment.

So, what do you think? Feel more confident in setting up an A/B test on WordPress now? If so, be sure to let me know how it goes.

Image Source: mil8


3 Responses

  1. RC Lations
    May 29, 2014 at 9:45 pm #

    You can also run more advanced experiments pretty easily too. For example if you want to run an experiment across all of your products, you can use –

    Paste Google’s Experiment Code Here

    There’s a couple additional setup options on the GA side I documented here –

    • RC Lations
      May 29, 2014 at 9:46 pm #

      2nd try pasting the code –

      if(is_product()) {
      Paste Google’s Experiment Code Here

  2. Steven Sashen
    June 17, 2014 at 7:33 pm #

    What I want to be able to test is FUNCTIONS not just layout. For example, I’d like to split test offering Free Shipping to see if the increased conversion makes up for the cost.

    Or offering Free Returns — which seems like it’s just a layout issue (presenting the information), but actually requires some data in the customer record that lets us know if the user was presented with that offer (so we know whether to honor it or not).


The most customizable eCommerce platform for building your online business.

  • 30-day money back guarantee
  • Support teams across the world
  • Safe and secure online payment
%d bloggers like this: