Resources     Blog  

  1. Home
  2. WordPress Tutorials
  3. How to Run WordPress A/B Testing in Google Analytics

How to Run WordPress A/B Testing in Google Analytics

Subtle changes in a layout can have a profound impact in the success of a post or page in WordPress. Things like headers, images, fonts and overall content can lead to successful conversions or a lack-luster performance. This is where WordPress A/B testing in Google Analytics comes into play.

By comparing the engagement of two or more similar pages, you can determine which is the more effective. It’s a great way to determine just how your target audience is interacting with the content while experimenting with how to develop your website.

In this tutorial, I’m going to show you how to use Google content experiments to improve your WordPress website. If you haven’t thought of using experiments before, you may be pleased by the results.

What Do You Need for A/B Testing?

The first thing you’ll need is a Google Analytics account. If you don’t already have one, you’re missing out on some valuable data regarding your website. It’s a free service the provides you with a slew of information from demographic data to how effective certain pages are in terms of value of AdSense.

You can sign up for your free account by visiting the Google Analytics website.

Once you have an account, you’ll need to attach it to your WordPress website. This is easiest by adding Google Analytics to your site through various plugins.

Personally, I prefer the GADWP plugin as it puts much of your data into the dashboard of WordPress making it easy to access from your website. However, there are plenty to choose from if you want to use something different.

Now, you’ll need the original content page and a variation you want to test it against. These need to be published and accessible to the public. Essentially, you’ll create two or more posts or pages in WordPress that are quite similar.

I know most SEO experts drill into your head about copying content or using the same keywords. However, this is not the same thing. For one, you’ll be removing several of these pages once the experiment is over and you have the results.

Secondly, experiments like these give you a chance to test out keywords and phrases to find the best fit for the content.

Creating a Content Experiment in Google

Once you’ve created an Analytics account, set up your website and added the code to your preferred plugin, it’s time to set up a content experiment.

Log into the Analytics account of the site you want to run an experiment on. If you have more than one website tied to your Google account, make sure you select the “All Web Site Data” option of the correct domain.

Under Behavior, click the “Experiments” option at the bottom.


Click the “Create Experiment” button.

Create Experiment

Give the experiment a name and assign an objective. For this instance, I am going to use “Pageviews” from the drop down window.

Name And Objective

Click the “Next Step” at the bottom.

Next Step

Input the URLs for the original page and the variant. You can add more pages by clicking “Add Variant.” However, you need at least one to run the experiment.

Add Variant

In the next step, click the button to “Manually insert the code” near the bottom.

Insert Code

For this next part, you’ll need to edit the theme files in WordPress. The code Google provides needs to be added to the header.php file of your current theme. You can access this file by using FTP programs like FileZilla, the File Manager in cPanel or by using the Appearance Editor in WordPress.

Paste the following code into the header.php file:

<?php if (is_page($page_id)) :
//Add Google Analytics Content Experiment

Place Google Analytics code here

<?php endif; ?>

Paste Code Header

Replace the “$page_id” portion of the code with the ID number of the original post. You can get this by looking up the post itself in the admin screen of WordPress. It will be in the address bar of your browser when editing.

Paste the code Google gives you to replace the “Place Google Analytics code here” text.

Once the code is saved into the header.php file, go back to Google Analytics. Click the “Next Step” button under the experiment coding.

Coding Step

You’ll see a confirmation message that Google has identified the code in your site and the experiment has launched. Now all that’s left to do is sit back and wait for the data to accumulate.

Depending on your objectives for the experiment, Google will show you which variant of your webpage is the most effective. If you’re looking at Pageviews, as in my example above, the system will show you which variant is getting the most traffic.

Data is Vital to Campaigns

Whether you’re developing a content marketing campaign or trying to figure out which landing page works best, Google Analytics content experiments are incredibly useful. They can help you fine-tune strategies and build a website that is everything you want it to be. Run your own WordPress A/B testing in Google Analytics and discover how you can create the best site possible.

How often do you check analytical data from your website? What metric is the most important to you?

Author: Kaumil Patel

Kaumil Patel is the Chief Operating Officer of GreenGeeks and has over 13 years of experience in the web hosting industry working for and owning web hosting companies. Kaumil’s expertise is in marketing, business development, operations, acquisitions and mergers.

Was this article helpful?

Related Articles

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.