GOOGLE‎ > ‎AdSense‎ > ‎

A/B Split Testing

The How-To of Creating an A/B Split Testing

I have heard of A/B Split Testing since forever it seems and it has always frightened me to bits in how complex it looked and all that interminable reading.  So here, I am going to try to make it as simple as possible so that even I can do it.

I am going to assume a number things here:
  • You know about AdSense ads (which I will be using as means of illustrative examples)
  • You know abit about Custom Channels (aka Ad Channels)
  • You already have ads running and want a way to find out if any variations in your ads will help increase your revenue stream

What is A/B Split Testing For?

A/B Split Testing example

In its simplest form, you only want to track:
    • page view/impressions
    • CTR (click-throughs) - i.e if your ad was seen a 100 times - how many times was the ad clicked? 
      1 time per 100 views ==> 1% CTR
      10 times per 100 views ==> 10% CTR

A/B Test = What If test

Say you have a page that has a square ad running on it. You wonder if having a rectangle ad in the same place, on the same page would make any difference.

A/B Split Testing example

In A/B Testing, ideally you want to:
  • do the testing on the same page (so you know that differences in results is not due to differing pages)
  • change only ONE feature between the 2 ads for each A/B Testing
    (either size OR color OR image/text, etc.)
  • though you can run these 2 ads by creating 2 new ads (& channels) - it would be preferable is you already had one of these running (so you have some recorded baseline performance) 
  • you MUST run both scenarios simultaneously (so a 50% rotation) - so that differences will not be due to seasonal effects

Then from the results (gathered over a couple of weeks at least), you will know which gives you a better return.

How to Do A/B Testing with AdSense and Custom Channels?

AdSense Small Square Ad Sample
I am going to use one of my current ads as illustration for this exercise.

Name of my ad unit/custom channel: JEM.SQ.T3.CTOPLEFT.IMG
(I have named using the same naming format for Custom Channels)
This ad also has an identical Channel name.

JEM - denotes the domain it is on
SQ - Small Square (200x200)
T3 - level 3 page (only applicable for my SBI site)
CTOPLEFT - in page's center column, Top Left
IMG - this is an image/media rich only ad
It is a small square (200x200)

This is what it looks like on my site: Jewelry Making Beads Library : Mother of Pearl Beads
AdSense Small Square Ad on JEM

Create another rectangle ad that is to be rotated 50% of the time, on the same page, in the same location, for a specific period of time and to analyse the comparative performance of each.

Since I already have one ad in place, I only need to create another ad (with only one different feature - here being: square vs rectangle [new])

1) Create New Ad: 
Log into AdSense Account > create a Medium Rectangle ad (300x250) and everything else between the 2 ads are identical except for the size.

==> new ad/custom channel: JEM.MRECT.T3.CTOPLEFT.IMG

Example Adsense code Ad1 and Ad2

2) Get Code of Ad 1 (sq) and Ad 2 (med redct) > paste each into Notepad  (you can tell which code is which by the name you have given it).  

To the left here, you can see I have copied and pasted both ad's code into my Notepad.
You can see I can tell the difference by the Name (as well as the size in this instance)

I have "(purple) boxed" each code for you to see - as these are the portions of code I want from each, viz.

from the opening to closing comment tag <!-- ... up to //-->

3) Create one block of code. 
This will be what you insert into your page (where you want the 2 rotating ads)

Copy this A/B Test block of code and paste into a new Notepad:

<script type="text/javascript"> 
  var random_number = Math.random();
  if (random_number < .5){
    //your first ad unit code goes here 
  } else { 
    //your second ad unit code goes here 
<script type="text/javascript" src=""> 

Then copy the "boxed" code from Ad1 (sq) and replace into where the yellow highlighted code is in the A/B Text block.
Coy the "boxed" code from Ad2 (med rect) and replace into where the green highlighted code is in the A/B Text block.

The final combined (AB Test) code will look something like:

Sample Adsense A/B Split Test code

Copy this entire block of code and paste into your page where you had the original Square Ad running.

4) That's it.  Monitor the performance of both channels 
over a period of 2 weeks or so and check against each other.  
You should also check against the baseline performance (if you had an original ad running, what was it's performance before you started the A/B Split Testing? 

Comparative Performance Criteria you might want to track are:
  • Page Views/ Impressions
  • CTR
  • estimated earnings

Note for SBI Sites:
As per illustrative example above, the code for my level 3 (T3) pages is not in each T3 page itself.  There are hundreds and that would be impossible to change all of them.

Rather the Google AdSense code should have already been in an include file (.shtml) 
Find that include file (view source of web page as a guide and check)
Into that include file, change previous AdSense ad code to the new A/B Test code.

Article written on 26 Jan 2012