AdSense Split Testing

As I’ve written before, the best way to optimize your AdSense earnings is through testing, because every site is different and what works on one site may not work on another. Only by testing different ad formats, placements and colors can you find what works best for your pages.

There are different approaches to testing, but the most popular is a technique called split testing, also referred to as A/B testing. Done properly, it’s a quicker way to find what works and what doesn’t, without affecting your earnings too negatively. Here’s what you need to know about split testing.

What is Split Testing?

Split testing is pitting two alternatives against each other to see how they compare. By directly testing alternative A against alternative B (hence the A/B testing moniker) you reduce the complexity of the testing scenario and can more easily determine what is working and what isn’t working. You then discard the “losing” alternative and pit the “winner” against a third alternative. You keep doing this until you’ve exhausted all the alternatives or you’re happy with the performance of the ultimate “winner”.

Optometrists use split testing during eye examinations. They place a complicated-looking device in front of your head, block off one of your eyes, and ask you to focus on a wall chart. They then start split testing different lenses: “Which one is clearer? This one or this one?” Eventually they land on the lens that works best for that eye.

Normally, the alternatives in A/B testing are tested using a 50/50 split so that each alternative is tested equally, just as the optometrist does in the previous example. You can vary the ratio to avoid rocking the boat too much, however, which is important when you’re testing a proven money-maker against an unproven alternative. When testing web pages, for example, you might show the normal page 90% of the time and the variation only 10% of the time. It takes longer to collect meaningful data, but the impact to your earnings will be minimal.

Split Testing AdSense

What kind of AdSense split testing can you do? There are many things to test:

You can also test search boxes and referral units. Really, there’s no end to the things you can test, and it’s up to you to decide what’s important. You may discover that an ad unit directly underneath the heading of a page or post maximizes your earnings but really interferes with the readability of your content, so you don’t pursue that path. It’s not my job to tell you what’s important, only to show you how to accomplish the split testing.

Split Testing and Custom Channels

The first thing you’ll need to do for split testing AdSense is to create some custom channels to track the alternatives. You’ll need two channels at a minimum: one for alternative A and one for alternative B. You should only test two things on a single page at any given time, otherwise you won’t really know which change is responsible for the increase or decrease in earnings.

Don’t go overboard with your custom channels. You don’t have to create a custom channel for each alternative you’re testing. Remember that multiple channels (up to 5) can be assigned to each ad or link unit, so all you have to do is add the “alternative A” or “alternative B” channels to the existing ad or link unit code. Just keep track of what it is you’re testing at any given point in time so that the reports are easy to sort out. The 24-hour block that starts at midnight PST (”zero hour” for AdSense) is the best period to use, since the earnings are reported on a daily basis. If you can’t time your tests that way, use different pairs of custom channels and switch over to a new pair when you change the tests.

Split Testing with PHP

The easiest way to do split testing is to add a bit of PHP to your files. PHP is a simple-to-use programming language for creating web pages. Please don’t be scared, it’s a lot easier than you think. All you do is take an HTML page and insert some PHP commands into it. When a web browser asks for the page, the web server runs the embedded PHP commands and the resulting page is what gets sent to the browser. (Such a page is usually called a “dynamic” page because the contents of the page are created or altered on the fly — dynamically — by the embedded code. Non-dynamic pages are called “static” pages.)

Normally this only happens for web pages that end in a “.php” extension, but a little “magic” can be used to make PHP work even with “.html” and “.htm” files. All you do is create a file called “.htaccess” (or edit the one that already exists) in the root folder for your site. At the top of this file, place these lines:

RemoveHandler .html .htm
AddType application/x-httpd-php .php .html .htm

This tells the web server to check all “.php”, “.html” and “.htm” files for embedded PHP commands. You can now go ahead and insert PHP code into any of your web pages. (There’s a slight performance penalty to pay, though, so when you’re done with testing and you don’t need to use PHP any more you can simply remove the lines above from the .htaccess file to re-enable the default static page behavior for .htm and .html files.)

Simple Split Testing

Now we’re ready to do some split testing. It’s actually very simple. Insert this somewhere at or near the top of the page:

<?php $splitpoint = rand( 1, 100 ); ?>

This generates a random number between 1 and 100 (inclusive) and stores it in the variable “$splitpoint”. You can now use this pattern throughout the file:

<?php if( $splitpoint > 50 ){ ?>
    <!-- put HTML for alternative A here -->
<?php } else { ?>
    <!-- put HTML for alternative B here -->
<?php } ?>

What this does is wrap your two alternatives with an “if/else” construct. Only one of alternative A or alternative B will be included in the HTML that is sent to the browser. In this particular case alternative A is used if $splitpoint is greater than 50, otherwise alternative B is used, which is the standard 50/50 split for testing. If you want to serve alternative A 80% of the time then you would change the condition to be:

<?php if( $splitpoint > 20 ){ ?>

You choose 20 as the comparison point because 100 - 80 = 20. (If you wanted to serve alternative A 20% of the time and alternative B 80% of the time, the comparison point should be 80.)

Here’s a simple HTML page that demonstrates the split testing at work:

<?php $splitpoint = rand( 1, 100 ); ?>
<html>
<head>
<title>Split Test</title>
</head>
<body>
<h1>Split Test</h1>
<p>The split point value is <?php echo $splitpoint; ?>.</p>
<?php if( $splitpoint > 65 ){ ?>
    <p>This text is shown 35% of the time.</p>
<?php } else { ?>
    <p>This text is shown 65% of the time.</p>
<?php } ?>
<p>Refresh the page to test it again.</p>
</body>

This page uses a 35/65 split to show two different lines of text. You can see the page in action on one of my sites. Refresh the page a few times to see the values change.

That’s all there is to simple split testing with PHP, and it works well with AdSense. Just replace the “alternative A” and “alternative B” blocks with the two pieces of AdSense code you want to test, each properly labeled with a different custom channel. Let the test run for a day or two and see which code made you more money. Repeat with the winner and a different piece of AdSense code. Do this as many times as you want, testing one or two small changes at a time until you’ve found the optimal solution for your page.

There’s more to write about split testing, but I’ll save it for another post.

Sponsored Link: Check out the Simple Cash Blog for some simple online money-making techniques that anyone can implement.

Eric Giguere is the author of Uncommon AdSense and the award-nominated (that just means it lost!) blog Make Easy Money with Google and AdSense. Subscribe to the blog and get free stuff!

Socialize This Post (Please!)

Add to OnlywireAdd to Onlywire

Comments

4 Responses to “AdSense Split Testing”

  1. Michelle on September 7th, 2007 10:19 am

    I do this exact kind of testing all day every day. It is incredible how effective this kind of testing can be. I hope you don’t mind but I gave you a backlink on my site http://www.monetizationweekly.com It is a compilation of articles about monetizing your website with google adsense. Come check it out if you’d like.

  2. Eric Giguere on September 7th, 2007 1:46 pm

    I never mind backlinks :-)

  3. Rafael - Seo on September 10th, 2007 4:58 am

    A valuable post. The Idea of Split testing is when you rotate your ads to find out which has the best clickthrough, generate one code you wish to beat the existing control using channels, Compare results on a day per day basis and you check the stats and keep the best performing ad. Eric Thanks for sharing it.

  4. Hybrid Ads: Links in AdSense Ad Units : Make Easy Money With Google And AdSense on September 10th, 2007 9:43 am

    [...] won’t see these too often. Google does split testing on these kinds of changes to see if they work or not. There is no way for you to opt out of these [...]

Subscribe without commenting