The skills we teach deliver real ROI.

A/B Testing with Google Analytics

A lot of conversion optimization companies out there are going to try to talk you into buying some fancy A/B testing software or hire their agency to run A/B testing for you. But for a lot of us in small organizations, the outrageous price for these services and software just isn’t doable. But fear not, I have a solution for you. And wait for it…IT’S FREE!

Setting up A/B split tests on landing pages is actually quite simple when using Google Analytics.  The example I’m going to be using is testing two different headings on a webform to see which version receives the most submissions.  Read on and I’ll give you step-by-step instructions for creating your first A/B split test with Google Analytics Experiments.

Creating an A/B Split Test with Google Analytics Experiments

Google Analytics doesn’t default to measuring user clicks, so you need to create an “onClick” event by adding some JavaScript to your button. Don’t freak out, you don’t have to actually know how to create a JavaScript. Here’s an example to go by.

onClick=”_gaq.push(['_trackEvent', 'Brochure Download', 'Download', 'BABC']);”

There are three required parameters in this JavaScript:

  1. Category = Brochure Download
  2. Action = Download
  3. Label = BABC

To learn more about the structure of this code, check out this Event Tracking post from the Google Developers blog.

Now for setting up your actual A/B test:

  1. Log in to your Google Analytics dashboard and select “Behavior” on the left.step1

    If you haven’t created a Google Analytics account yet, check out a recent blog post with complete instructions on Creating a Google Analytics account.

  2. Once you’ve opened the Behavior drop-down, choose “Experiments.”step2
  3. Once you’re inside Experiments, you’ll need to select “Create experiment” to get started.step3
  4. Name your Experiment and then choose your objective. For this test, you’ll need to choose “Create a new objective.”step4
  5. You’ll be taken to the “Goals” screen where you’ll need to name your goal and choose the type of goal. Since we are testing clicks on a webform, we’re going to select “Event” as the type of goal and then click “Next step.”step5
  6. Next you’ll need to specify the “Goal details.” Use the dropdown next to “Category” to select “that is equal to” and then type in the category you used in your JavaScript we created earlier. Now Google know that whenever the “Download Brochure” event occurs on the page to count that as a “BABC Brochure Download.” Now select “Create Goal” to move on to the next step.step6
  7. After you create your goal, you’ll remain in the Goals menu, so you’ll need to go back to Experiments.*Note: Take a look at what is listed under “Id” next to the name of your goal in the Goal’s list before you leave. You will need that information in a little bit.


    Select “Reporting” on the top navigation to get back to your Experiments window.


  8. Select your Experiment under “Experiment Name” to continue editing you A/B test.step8
  9. Now that you’ve created your Goal you can select your metric as the objective for this experiment. This is where knowing what is listed under “Id” next to the name of your goal in the Goal’s list comes in handy.step9

    I know that my goal was “Goal Set 1” and “Goal ID 5.”


    Select the percentage of audience to include in the experiment and then click “Next Step.”

  10. This is the part of your A/B test configuration where you can choose both versions of the page you want to test against each other. Paste in the URLs of both versions of your page and name each version. Since we’re testing headline copy on webforms, I’m going to name the page based on the differences in the copy. Once you’ve put in the URLs of both landing page variations and named each version, click “Next Step.”step10


  11. The final step in setting up your A/B landing page test is deciding how to set up the experiment code. You have two options: You can either manually insert the code yourself, or send the code to your webmaster. I’m going to select the option to manually insert the code myself and then I’ll show you where to put it on your landing pages. 


    You’ll then be given a giant script to add to your landing pages: 


    This code will need to be added immediately after the opening <head> tag at the top of your original landing page. 


    *Note: This can be confusing. You need to make sure that your Google Analytics Tracking code is on both pages, but the experiment code only goes on one page.  This is also reviewed in my previous post about creating a Google Analytics account. 

    Make sure you upload your changes once you’ve added this code to your original page. Once you’ve uploaded your changes, click “Next Step” to validate the code, review your A/B test configuration and run the experiment.

Voilà! You’ve set up your first A/B landing page test. Happy testing! Now go impress everyone with how smart you are!

Leave a reply