A/B Testing



Save this to Del.icio.us

A/B Testing

Background Information

A/B testing is a method used in order to increase the effectiveness of Google AdSense ads by comparing the performance of 2 different advertisements (A and B). This approach is most appropriate for improving the performance of an ad by changing it's appearance (color of the text, color of the border, shape of the ad etc...) instead of actual ad placement (where the ad is located on the page).

So What Actually Happens in A/B Testing?

The best way to clarify things is to explain using an example so please consider the following situation. You have a webpage with an AdSense content unit placed within the main content of the page (text). The ad unit has a border around it at present and you want to know if removing the border would have any positive effect on the performance of the ad. This is where A/B testing comes in.

Google AdSense A/B Testing

A/B testing makes use of Google AdSense channels. Basically what you are doing is showing 2 different ads in the same location and seeing which performs better by monitoring them closely using the channels.

This obviously means that you need 2 seperate channels, 1 for each of the 2 ads. Make sure you create channels with concise names, for example if I were to be using A/B testing on this site I could use:

  • STC Header A
  • STC Header B

These channel names are very concise, yet tell me everything I need to know about the channels. "STC" tells me that the channel is for an ad on "SiteToolCenter", "Header" tells me that the ad is placed just under the header of each page, and "A" / "B" tells me whether it's the statistics for ad "A" or ad "B".

Once the channels have been created the next step is to find a way to automatically serve both ads. You ideally want the ad show ratio to be 1:1, i.e. if 1,000 visitors view a page ad "A" and ad "B" should be shown 500 times each. There are many different methods that could be used to do this but I am going be using PHP in this case.

Implementation of A/B Testing Using PHP

I am going to give a step-by-step guide on how to implement A/B testing using PHP in case you are unfamiliar with the idea.

The first thing you should do is to create a webpage with the extension ".php", for example try creating a webpage with the name "testPage.php". We are going to take a really simple approach to serve the 2 different ads. Take a look below to see what we are going to do:

  1. Generate a random number between 1 and 2, and store this as a variable "".
  2. If variable "" is equal to 1, store the AdSense code for ad "A" in a different variable "". Else store the AdSense code for ad "B".
  3. Show the page to the visitor with the relevant ad.

Now that we know the exact course of action, let us look at the code:

A/B Testing PHP Code


// Generate a random number between 1 and 2
// and store it within
$randNum = rand(1 , 2);

// If is equal to 1, store the AdSense
// code for ad "A" in
if ( == 1){
$adCode = '

AdSense Code for ad "A"


// Else store the AdSense code for ad "B" in
else {
$adCode = '

AdSense Code for ad "B"


// Now print out the page
print <<<HERE

<!-- Begin HTML Code -->

<title>A/B Testing</title>

<h1>A/B Testing Example</h1>

<div style = "float: left">

<p>Page Content Here</p>


<!-- End HTML Code -->



This is an example of how A/B testing could be carried out. With the above example, place your relevant AdSense code and content into the appropriate parts of the code marked with red text. Copy and paste this (from <? to the final ?>)into your "testPage.php" upload it to your server. If you know view the page, it should show ad "A" 50% of the time you load the page, and ad "B" the other times.

Monitoring Performance of the Ads

Now that you have A/B testing setup on your webpage, you will need to closely monitor the performance of each of the ads. Luckily for you Google automatically stores all of the channel data in their database.

Displaying Your A/B Testing Results

To view the results of your A/B testing, you will first need to login to your Google AdSense account. From there follow the following steps:

How to Display Your A/B Testing Results

  1. Click on "Reports -> Advanced Reports".
  2. Select "All Time" from the "Choose Date Range" section.
  3. Select "Channel Data" under the "Show" heading.
  4. Select the 2 channels you used for the A/B testing from the "Active Custom Channels" list on the right hand side of the screen.
  5. Select "Channel" under the "Group By" section.
  6. Click on Display Report.

Analyzing the Results of Your A/B Testing

How to Analyze Your A/B Testing Results

If you follow the steps outlined in the above section about displaying the results, you should be presented with a table similar to the screenshot above. Analyzing the results is pretty self-explanatory. In this particular case advertisement A (a text ad) performed 570% better than ad B (an image ad).

Now considering this site is a low earnear this might now seem that significant right now but if you think about it systematically you will soon realize the huge impact it has on your earnings. Changing all the ads to type A would theoretically increase the revenue earned during this time period to $12.00. Now think about this over a year, 5 years, 10 year period... It does make a huge difference in the long term.

Caution About A/B Testing

Make sure you are not too hasty when deciding which advert performs better. The longer the time you sample the more accurate your results will be. However if you leave it too long you are missing out on potential income! You therefore need to make a compromize between the 2. A reasonable sampling time is 1 to 2 weeks.

A Final Word

This is obviously just an example so you do not have to keep to what I done here. To change the webpage that is shown, place your HTML code between the "print <<<HERE" and "HERE;" tags.

Now that you know about A/B testing, you should read the tutorial on How to Make the Most of A/B Testing.

[ Back to Google AdSense Optimization ]

Forums | Search | Donate | Links | Contact | Templates | Privacy Policy
Copyright © 2018 SiteToolCenter.com

Website Design

Best Viewed With Mozilla FireFox