AB Split Testing in WordPress Themes by Google Analytics

A/B split testing isn’t a buzz term. A lot of savvy marketers and designs are using it right now to gain insight into visitor behavior and to increase conversion rate. And yet A/B testing is still not as common as such Internet marketing subjects as SEO, Web analytics and usability. People just aren’t as aware of it. They don’t completely understand what it is or how it could benefit them or how they should use it. This article is meant to be the best guide you will ever need for A/B testing.

What Is A/B Testing?

At its core, A/B testing is exactly what it sounds like: you have two versions of an element (A and B) and a metric that defines success. To determine which version is better, you subject both versions to experimentation simultaneously. In the end, you measure which version was more successful and select that version for real-world use.

This is similar to the experiments you did in Science 101. Remember the experiment in which you tested various substances to see which supports plant growth and which suppresses it. At different intervals, you measured the growth of plants as they were subjected to different conditions, and in the end you tallied the increase in height of the different plants.


A/B testing on the Web is similar. You have two designs of a website: A and B. Typically, A is the existing design (called the control), and B is the new design. You split your website traffic between these two versions and measure their performance using metrics that you care about (conversion rate, sales, bounce rate, etc.). In the end, you select the version that performs best.

All in all, this is where A/B Split Testing comes in. It allows you to test different versions of a page to find out which version gives the best results. It is a commonly used technique by many professionals to improve their website’s conversion. In this article, we will show you how to do A/B split testing in WordPress Themes by Google Analytics.

Preparing for A/B Split Testing

Before we move forward, there are a few things you would need for this tutorial. If you haven’t already done so, then the first thing you need to do is install Google Analytics in your WordPress themes. The second thing you would need is variations of the original page that you want to test. For example, if you are running tests on your registration page, then create another copy of the page with different copy, style, or layout. You can create multiple variations of a page with different layouts or copy. Make sure that you publish your original page and all its variations, so that they are publicly accessible.

Setting up Content Experiment in Google Analytics

A/B split testing is called Content Experiments in Google Analytics. Sign in to your Analytics account and then go to Content » Experiments. Provide the URL of your original page and click on create experiment button to get started.


abtesting-analytics-startOn the next page you will be asked to provide a title for this A/B testing experiment and choose an objective for it. Objectives are goals which you can create in Google Analytics. You can create a new goal by clicking on add an objective link, or use an existing one. Analytics will track how many visitors to each variation of page meet your objective or goal. For example, if you have a registration page where users are redirected to a thank you page after registration, then you can set that as your objective. When a user on your website fills the form and gets redirected to the thank you page, then this equals to the completion of your goal.


After providing your original page URL and choosing objective or goal for this experiment, you can now add variations of this page. Create different variations of this page in WordPress themes and make sure all of them are live and publicly accessible. You can add multiple variations of the same page with different design, call to action, layout and copy.


On the next screen you will be provided with a code to add to your WordPress website’s header. Click on Manually insert the code button and copy the code.


Now all you need to do is add this code to your WordPress theme’s header.php file. Once added, this code will start redirecting all visitors to a variation of your testing page. To add the split test code, you need to paste this code in your theme’s header.php file:

 <?php if (is_page($page_id)) : //Add Google Analytics Content Experiment ?> Paste content experiment code here <?php endif; ?> 

Replace $page_id with the id of your original page. (See how to find a page ID in WordPress)

If you don’t want to modify the code in your theme, then you can use this plugin called Google Content Experiments.

Once you have added the code to your original page and published the original and variation pages, go back to Google analytics and click the Next button. Analytics will now verify that you have the content experiment code properly installed on your pages. After that you can click on start experiment button to launch your A/B split testing content experiment.


That’s all you need to get started. You have successfully installed A/B Split Testing on your WordPress site using Google Analytic’s content experiments. It will take some time before Google Analytics will start showing test data. Visitors to your original page will now be randomly redirected to one of the variation pages and some would still see the original page. Users will continue to see the same variation of the page on their next visits during the experimentation. Based on your goal settings, Google Analytics will show you which variation is working best towards achieving your goal and will choose a winner if it feels that one variation is out-performing other variations of the page.

About the author: Arthur Sereno