What's WP
Our everything is about WordPress - best choice of WordPress users!
How to Conduct an A/B Split Testing in WordPress with Google Analytics

How to Conduct an A/B Split Testing in WordPress with Google Analytics

Web content optimization is an important method to push your website to a new high and that is of great concern. Since there are several content designs available for you and it is hard to make decision which one will be favored by visitors, then you should go with A/B testing. That is a practical way to help you make up your mind.

Given that how to conduct an A/B split testing in WordPress becomes a new concern of most readers, we make this guide to remove all doubts. A brief lead-in on what is A/B testing comes upon how to conduct such a testing with Google Analytics Content Experiments.

What is A/B Testing?

A/B testing, as its name suggests, is used to test two or more versions of the same object which can be a page design, a product, a post or something else. Both A and B versions are made public thereby leaving a chance for all visitors to make a choice between two options. After testing, the more popular version stays on your site while the other one should be sifted out.

Undoubtedly, A/B testing gives you the opportunity to know your visitors so as to cater to their pleasure. That encourages more potential visitors to be long-term visitors and accelerates website traffic in an effective way.

Some Do’s or Don’ts about A/B Split Testing

Before learning the detailed steps, you firstly need to know some do’s and don’ts for carrying out the split testing effectively.


  • You have to decide the exact time range for this testing. After all, stop the test too early may cause some losses on the real meaningful results. If you test for a long time, the poor performing variations can do no good to your site.
  • In order to prevent blunders, you need to showcase the same variations for the same visitors.
  • You can do multiple A/B tests for the most precise results. Generally, you can get three outcomes from the tests – no results, positives ones and negatives ones. If you carry out tons of split tests and get the all positive results, you can make some modifications on your sites without any worry.


  • You can never test your two versions at different times. They need to be monitored simultaneously.
  • Do not conclude the result too early, but keep a deep insight into your website changes with repeat testing.
  • Do not affect your loyal and regular readers. You’d better only include the new visitors into your testing.

Lay the Groundwork for A/B Testing

Content Experiments is subject to Google Analytics. To make it into effect, you are required to add Google Analytics to WordPress at first. Log into your WP admin and search for Google Analytics plugin via Plugins > Add New. That is the most popular way to enable Google Analytics on the whole website.

install google analytics

After completing the installation, there is a new item named as Google Analytics included in Settings. Go to Settings > Google Analytics and here requires you to enter a Web Property ID, which is generated since you have signed up an account on Google Analytics. If you have not registered an account, go to Google Analytics and get your own account right now.

Since everything is ready, a tracking ID and lines of tracking code are shown on the Google Analytics admin page. Copy & Paste the tracking ID to Web Property ID field and click “Save Changes”. Besides, the tracking code can be inserted into any page you want to track.

web property id

Conduct an A/B Testing in WordPress

Go back to Google Analytics official site and sign in your account. Target “Reporting” tab and move to the sidebar on the left page where shows you a list of options for website analysis. Access to Behavior > Experiments > Web Experiments and click “Create experiment”. There are 4 steps available for experiment customization and the first step requires you to name the experiment properly.

choose an experiment objective

Go to the “Next Step”. This is where to configure your experiment and copy & paste the URL of pages to experiment in the blank. Note that, you are allowed to add more than one variations according to personal needs. Click to the next step.

configure your experiment

Here shows you lines of code to insert into your header.php file. Select a proper way to set up your experiment code from two options, including “Manually insert the code” and “Send the code to webmaster”. We choose the first way to go ahead. Insert the content experiment code into the following lines of code and then copy & paste this code to the header.php file of your active theme.

<?php if (is_page($page_id)) :
//Add Google Analytics Content Experiment
This is where to paste your experiment code
<?php endif; ?>

Remember to replace $page_id to an ID of the original page. Find out the page ID correctly via your WP admin and that is shown on the address bar.

The additional details of your experiment code are shown below the script code, including Experiment ID and Experiment Key. Keep them secret for which are exclusive for you. And then, go to the final step.

setting up your experiment code

Move to the last step “Review and start”. Since everything gets ready and there is no error happening to the original and variation, click “Start Experiment” and get a notice said “Experiment launched”. And now, you have successfully launched your first experiment.

experiment launched

Go to experiment list and this is where to check all experiments you have created just now. Each experiment comes with a brief explanation on status, details, sessions, start date and end date. Click any name of an experiment to modify it if needed.

If You Wish to Get More Methods

Besides the method mentioned above that helps to conduct A/B split testing easily, you are allowed to do so via WordPress dashboard by using a content experiment plugin. That is Google Content Experiments. This plugin is a great option for users sick of making any change to theme’s file and it is specialized in A/B split testing. Install and activate this plugin via you WP admin.

install google content experiment

Since the “Google Content Experiments settings” is available for all pages/posts, you have successfully installed and activated Google Content Experiments plugin. Before everything, you should access to Experiments dashboard at Google Analytics. Choose an experiment objective at first and then enter the original page URL & variation URL in the field. Click “Next Stop”.

The “Setting up your experiment code” area displays lines of code and that should be included in the original page. Go back to your WP admin and “Edit” the original page. Scroll down this page and focus on Google Content Experiment settings. Check the option “Page is the original page of a Content Experiment”. An area to insert Content Experiment code is expanded for you. Copy and paste the lines of code to this field and publish your page/post.

google content experiment settings

Then, go to the final step “Review and start” and click to start experiment. To get more details about this newly created content experiment, you need to click the name of this experiment and access to an interface where displays detailed information for your reference.

check content experiment

If the pitch on in this guide cannot satisfy your needs, there are more content experiment plugins available for you to choose from, such as Split Test Dynamo, A/B Theme Testing, Optimizely, and so on. Select the preferable one to go ahead your plan. We hope the recommended methods can help you make a hit.


Lucy has been a very experienced SEOer, technical writer, web developer, c# developer since 2002. Now she owns a startup in San Francisco, CA, focusing on running a couple of blogs to share knowledge and experience with global readers and deliver exceptional results to global sponsors by leveraging the power of Internet.


Want to Learn More About WordPress?

Get Our Free Themes, Plugins, Support, SEO Tips, and Other Tutorials!

Email *