There are two reasons you’re probably not A/B testing your website:
- It’s kind of expensive ($59 for first tier of VWO)
- It’s complicated (“I’m no good at math”)
Tell you what. In this post, I will show you how you can set up your first simple test completely for free.
Do you need any special skills? No. Do you need to sign up for a trial of an expensive A/B testing software? No.
The stack we’ll use is: Google Analytics Experiments and WordPress. That’s it!
I recently learned how to do this when I tested the home page of this website. Along the way, I encountered a number of stupid obstacles — fortunately, you will not have to face those as I’ll guide you by the hand through every step of this case study.
But first, why not share this post on Twitter, like Google Analytics did?
— Google Analytics (@googleanalytics) April 8, 2016
What will you compare?
A/B tests usually start with a design problem. Some design problems are fairly straight-forward, but some not so much.
I had wondered if adding download boxes below the sign-up for on the home page will decrease the bounce rate on that page. Here’s what the original page looked like:
First step for you is to figure out what part of the website do you even want to test. Some ideas are:
- Button colour
- Product image
- Blog post layout
- Page and copy length
- Location of call to action
For setting up your first A/B test, it’s best to pick just one large thing to test. But even for the seasoned testers, sticking to few but bold changes will produce the best results.
Define your goals
To determine which one of the two variants is best, you’ll want to first decide the criteria. It’s best if you only pick one important goal for each test. Sometimes, the results will oppose each other (for example, higher bounce rate but more conversions), so you’ll want to keep focused on the one metric you want to improve.
Examples of goals are:
- Bounce rate
- Newsletter sign-up
- Trial sign-up
- Completing a purchase
- Clicking a button
- Viewing a product
- Adding product to cart
- Reading 3 articles
- Staying on a page for 5 minutes
- Playing a video
- Downloading a freebie
Once you’ve decided on a goal, you’ll need to set it up in Google Analytics.
In my case, I measured bounce rate. But let’s say for the purpose of this tutorial, that I want to measure newsletter sign-ups instead. The final step in the sign-up process is the thank you page, so my goal is going to be visits to that page.
Note that I could measure clicks on the “Sign up” button, but not all of those clicks will go on to actually complete the subscription process. Therefore, setting up the button clicks as a goal would likely give me skewed results.
Here’s how you set up the goals in GA:
Create the different variations
Next, you’ll create the two different pages to compare. Google Analytics will then direct the visitors among the two pages until it determines the winner.
Now hold up, Heidi, don’t two pages with the exact same content cause problems with SEO?
Yes, they do. We’ll fix this later in this post.
But for now, simply duplicate your original page (Variant A) and modify it to create the alternative (Variant B).
It’s best to only test a single change, like a headline or button colour. If you change multiple things in the page, you’ll have a hard time telling which change produced the results of the test.
In my test, I took the home page, and created a new one in WordPress. Then simply tweak the element you want to test and publish the page.
Just as a side note, don’t worry about the design being perfect on the tests. Small hiccups in spacing or the wrong font won’t affect the end result. You can polish the final design when your tests finish.
Make it SEO friendly
Google doesn’t like similar content on multiple pages on your website. They may view your A/B tests as an effort to puff up your website with copied and pasted content. No bueno.
This is why we’ll use the noindex and canonical URL on the alternative page variant.
The noindex tag will make sure that Google doesn’t index and rank Variant B and screw with your results by bringing extra visitors to it. Add this code to header:
<meta name="robots" content="noindex">
The canonical URL will point Google to the original page and protect our site from being penalized for duplicate content. Replace the “[url to A variant]” and paste into header:
<link rel="canonical" href="[url to A variant]" />
If you use the Yoast SEO WordPress plugin, this is easy as a pie. Simply fill out this form on your Variant B page:
Create the A/B test in Google Analytics Experiments
Now that you have the two pages live, the rest of the process is fairly straight forward.
Unlike setting Goals, you create a new Experiment within the reports. Navigate to Behaviour > Experiments and click “Create Experiment”.
Choose an experiment objective
Name your experiment whatever you want. At the end of this setup, you will be able to also add some notes, so don’t worry about the name being too descriptive.
Under Objective for this experiment, pick the goal we set up in step 2. In my case, I’ll pick “Newsletter sign-up”.
Unless you have huge traffic, leave Percentage of traffic at 100% and skip to next step.
Configure your experiment
Here’s where you paste in the two urls to the pages created in the first step. Name them something descriptive and check off Consolidate experiment for other content reports.
You may get the “We could not find the URL that you entered Please check the URL and try again” message. I wasted a ton of time trying to troubleshoot this — there’s no solution. Apparently, Google Analytics just needs some time to load the URL. Triple check the URL you pasted in, check if the page is online, and then move on. Don’t worry, the test will work!
Setting up your experiment code
This is where it gets a bit tricky. Click Manually insert the code and copy the block of code that will appear below.
The code must be inserted before the regular Google Analytics code, within the <head> tags. In WordPress, you’ll paste the code inside the header.php file by simply navigating to Appearance > Editor.
The following workaround is only necessary for those of us who use a WordPress plugin to insert the regular Google Analytics code. Skip ahead if you don’t!
Plugins like Yoast Google Analytics insert the regular GA code at right after all the required WordPress scripts, making it impossible to simply paste our new Google Analytics Experiments code before it.
This is very sucky. One solution is to stop using that plugin and simply paste the regular GA code into your header.php. But if you’d like to continue using the plugin, there’s a workaround!
Navigate to Appearance > Editor, pick functions.php on the right, and paste the code above to the end of the document. There are three edits you’ll need to make to the code:
- Replace the Experiments code with your own
- Replace is_page(XXXX) with is_page() || is_page() to insert into two pages
- Insert the page ID’s in the is_page() commands (here’s how to find your ID’s)
If you’re testing posts rather than pages, replace is_page() with is_single().
Review and start
Now, you can click Next step in Google Analytics and wait until the tool validates your code. If it fails to do so, your Experiments code is likely below the regular Google Analytics code. You’ll need to fix it before completing the process.
Click Start experiment and have a cookie. Like, an actual cookie. You successfully set up an A/B test!
Review the results
Analytics will automatically run until it determines a winner. After the test has completed, you can review the analytics by clicking on a test.
As you can see in this case, the original page showed a much lower bounce rate. You can use the tabs on top to review the variations against other goals you have set up (red arrow in the image below).
The data on conversions in this test supported the finding that the original version is better than the one with boxes. I decided to keep the design as it is, but will test more variations in the future.
You managed to get valuable information from your visitors, and totally for free. Your next step is to keep testing different parts of your website and determine what combination brings you the most conversions.
A/B testing never ends, really. You’ll want to keep on testing with every new page, strategy, product, or other addition. What will you test next?
Design, but simple.
My popular design ebook is now on sale. Don't miss out!