How to use Google Analytics Content Experiments

Today I’m going to show you how to set up A/B testing with Google Analytics Content Experiments.

You may be asking yourself what is “A/B testing”? Well as always I think the best way to explain is to provide a real world example. We’ve just launched our new site, a premium site where users subscribe to get access to over 325,000 icons.

We had two ideas for the sign up page where users purchase our subscription one was long with FAQ’s and one was short with a different sales pitch heading. Now wouldn’t it be great to have some users go to sign up “page A” and some users go to sign up “page B” and track which page results in more sale conversions for our site? Google Analytics Content Experiments allows us to do just that.

We are going to define a control page (page A) and a variation (page B) and expose our users to the different versions of the page to determine which version will result in more conversions.

First you’re going to need a Google Analytics account and already have your Tracking code installed on your website, if you don’t already have a Google Analytics account you can sign up here:

If you need help installing your tracking code see here:

To create a new experiment navigate to the Behavior section and click on the Experiments link on the sidebar. Above this table, you will find a button Create experiment, click on it.


Now lets set up our experiment!

Choose an experiment objective

Name for this experiment: Name your experiment, ours is Icons Pro Sign Up.

Objective for this experiment: Google Analytics Content Experiments needs a metric by which the experiment gets evaluated, for us this is our order confirmation page that the users gets redirected to from PayPal after purchase. If you already have an existing goal click Select a metric. If you don’t have an existing goal, Ecommerce or AdSense metrics click Create a new objective.


Note: You can skip this steps if you already have an existing goal.

Goal setup: For the goal setup, select Custom and then click Next step.

Goal description: Enter the Name of your goal description, ours is IconsETC Order. Next for Type select Event then click Next step.

Goal details: Fill in all the Event conditions, leave the Value blank, also the option Use the Event value as the Goal Value for the conversion should be set to Yes. Below is what we used for our Event conditions:

  • Category "Equals to": Icons Order
  • Action "Equals to": action
  • Label "Equals to": Completion Page
  • Value "Greater than": Leave this option blank, do not enter anything


Next click Create Goal, now we have our goal.

After you’ve created your goal click on the Reporting menu option in the main Google Analytic menu next to the logo at the top of the page, this should take you back to the All Experiments page.

Click on the title Icons Pro Sign Up or whatever your experiment name is to continue setting up our experiment.

Now under the Objective for this experiment option select click on Select a metric then click on Goal Set 1 then select your goal, in our case IconsETC Order.

Percentage of traffic to experiment: We’re going to send 100% of traffic to the experiment. If your experiment is drastic and risky, you might want to include only a small proportion of your site's visitors.

Email notification for important changes: Set this to ON

Advanced Options: For our experiment, there is no need to change the default Advanced Options. If you’d like to read more about what these options are click here:

Click Next step.

Configure your experiment

Original Page: Here is where we define our original sign up page, there are two options, for us they’re as followed:

  • Web page to experiment:
  • Name for the page: Original

Also, Enable the checkbox Consolidate experiment for other content reports, so that all the different pages of the experiment appear as one in the standard Google Analytics reports.

Variation 1: Here is where we define our first variation page there are two options, for us they’re as followed:

  • Web page to experiment:
  • Name for the page: Risk Free


Click Next step.

Setting up your experiment code

How do you want to set up your experiment code?: Click Manually insert the code and insert the code directly under the opening <head> tag at the top of your original page only, in our case this page was


After you’ve inserted the Google Analytics experiment code directly under the opening <head> tag click Next Step, Google Analytics will test and make sure the code was correctly inserted.

Note: If you’re using a CMS like WordPress for instance you may be using the same header.php for all your pages, in this case you’ll need to wrap the code in a PHP - If () Condition so that the Google Analytics experiment code only shows up on the page you want it to, we used the following code below, all we needed was the page ID for our original page

$pageid = $wp_query->post->ID;
if( $pageid == 3519 ) { ?>
<!-- Google Analytics Content Experiment code -->
<script>function utmx_section(){}function utmx(){}(function(){var
function f(n){if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.
indexOf(';',i);return escape(c.substring(i+n.length+1,j<0?c.
length:j))}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;d.write(
'<sc'+'ript src="'+'http'+(l.protocol=='https:'?'s://ssl':
'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='+new Date().
'" type="text/javascript" charset="utf-8"><\/sc'+'ript>')})();
<!-- End of Google Analytics Content Experiment code -->
<?php } ?>

Goal Code: Remember the Goal we setup in Step 1 under the Objective for this experiment option? Again this is how the Google Analytics Content Experiments winner is chosen. So in our case we need to put the following code on our Order Conformation page just before the closing </head> tag, the page that the user is redirected to from PayPal after a successful payment, make sure that this code comes before your Google Analytics Tracking Code.

Again if you’re using a CMS like WordPress you may be using the same footer.php for all your pages, in this case you’ll need to wrap the code in a PHP - If () Condition so that the Goal code below only shows up on the Order Conformation page:

ga('send', {
  'hitType': 'event',         
  'eventCategory': 'Icons Order', 
  'eventAction': 'action',     
  'eventLabel': 'Completion Page',

Review and start:

If Google Analytics Experiment Code Validation is successful click the button Start Experiment.


Final Thoughts

It may take up to 24 hours for Google Analytics to start tracking your experiment so don’t worry if you don’t see results right away. Also, no need to stop at just two variation pages, Google Analytics Content Experiments will allow you to run up to 9 page variations in one content experiment.

You might also like
Adding Versatile Button Shortcodes to your WordPress Theme Image Masking and Sliding Transition Effect Create a Professional Coming Soon Landing Page PSD Template Dejavu Wordpress Theme Elegance Wordpress Theme Glossy Black Button Icons Brushed Silver Reflective Text Effect Yellow Road Sign Icons Glossy Silver Web 2.0 Icon Tutorial Method Wordpress Theme Echelon Wordpress Theme Matte White Square Check Mark Icon Coffee Stain Social Networking Icons Tutorial Data URI Tileable Transparent Patterns Persuasion Wordpress Theme Blue Retro Grunge Text Effect and Icons Starfield Tileable Twitter Background Tutorial Myriad Wordpress Theme Crystal Clear Bubble Icons Fusion Wordpress Theme Modular Wordpress Theme 3D Transparent Glass Text Effect Grungy Rusted Carbon Fiber Text Effect Grunge Yellow Warning Striped Icon & Text Effect

0 comments on “How to use Google Analytics Content Experiments

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>