Free Script For Split Testing Adsense Color, Size, and Placement

I'm working on a new project at HowToSaveElectricity.net. Primarily, this site is going to be monetized with Adsense. The only way to make sure I'm getting the most of my Adsense ads is to test the different options from placement, pic vs text, size, and color.

If you take a look at the how to save electricity article on this page, you will see up to 4 different variations of the Adsense ads in the body of the article. These variations include a pic to the left, a pic to the right, text to the left, and text to the right. Every time you refresh the page, you have the potential of seeing another version of the Adsense placement.

Currently, I'm running four different options. Potentially, you could make a small modification to the code and run as many different options as you want. Due to the low traffic to this site, I decided to start with four.

Here are the steps for setting up a test.

1. Setup an Adsense ad for each variable you want to test and assign a unique tracking channel to each one. This is done inside of your Adsense account.

2. Past the following code into your page.  You'll need to fill in your publisher id, ad size, creation time, and ad slot information.  Be careful, if you get just one quotation or semi-colon our of place the code will not work correctly.

<?
srand(time());
$random = (rand()%3);

if($random == "0")
{
echo "<div style=\"float:right; padding: 10px 10px 0 0;\">\n";
echo "<script type=\"text/javascript\"><!--\n";
echo "google_ad_client = \"pub-XXXXXXXXXXX\";\n";
echo "/* 300x250, created 11/16/09 */\n";
echo "google_ad_slot = \"XXXXXXXXXXXXXXXX\";\n";
echo "google_ad_width = 300;\n";
echo "google_ad_height = 250;\n";
echo "//-->\n";
echo "</script>\n";
echo "<script type=\"text/javascript\"\n";
echo "src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n";
echo "</script>\n";
}
elseif($random == "1")
{
echo "<div style=\"float:right; padding: 10px 10px 0 0;\">\n";
echo "<script type=\"text/javascript\"><!--\n";
echo "google_ad_client = \"pub-XXXXXXXXXXXXXX\";\n";
echo "/* 300x250, created 11/18/09 */\n";
echo "google_ad_slot = \"XXXXXXXXXXXX\";\n";
echo "google_ad_width = 300;\n";
echo "google_ad_height = 250;\n";
echo "//-->\n";
echo "</script>\n";
echo "<script type=\"text/javascript\"\n";
echo "src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n";
echo "</script>\n";
}
elseif($random == "2")
{
echo "<div style=\"float:left; padding: 10px 10px 0 0;\">\n";
echo "<script type=\"text/javascript\"><!--\n";
echo "google_ad_client = \"pub-XXXXXXXXXXX\";\n";
echo "/* 300x250, created 11/18/09 */\n";
echo "google_ad_slot = \"XXXXXXXXXXX\";\n";
echo "google_ad_width = 300;\n";
echo "google_ad_height = 250;\n";
echo "//-->\n";
echo "</script>\n";
echo "<script type=\"text/javascript\"\n";
echo "src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n";
echo "</script>\n";
}
else
{
echo "<div style=\"float:left; padding: 10px 10px 0 0;\">\n";
echo "<script type=\"text/javascript\"><!--\n";
echo "google_ad_client = \"pub-XXXXXXXX\";\n";
echo "/* 300x250, created 11/18/09 */\n";
echo "google_ad_slot = \"XXXXXXXXXX\";\n";
echo "google_ad_width = 300;\n";
echo "google_ad_height = 250;\n";
echo "//-->\n";
echo "</script>\n";
echo "<script type=\"text/javascript\"\n";
echo "src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n";
echo "</script>\n";
}
?>
</div>

3.  The code works by randomly picking a number between 0 and 3 each time the page loads.  The random number determines which version of the adsense ad is displayed on your page.

4.  Now you can run a report from you Adsense account to determine which version of the ad provided the highest eCPM.

A Couple of Tips

1.  Be careful with this code or any code that works with your Adsense code.  The Adsense TOS prohibits any modification of your Adsense code.  If you are caught modifying it, chances are you will lose your Adsense account.  The code I featured above does not modify the Adsense code in any way. If you check the source code on a processed page, you'll see it displays exactly as it is shown on the Adsense site.

My concern is if you are not comfortable placing your publisher id or other ad data into the code, you could do something wrong and potentially modify your Adsense code.  If you aren't comfortable running this test yourself, get some help or don't do it at all!

2.  Don't make a quick decision.  You'll need more than just a couple dozen impressions to determine which ad version is a winner.  I'm not willing to pick a winner until I have several thousand impressions and possibly more if my results are still too close to call.

3.  I'm more interested in picking a winner from (eCPM) effective cost-per-thousand impressions and not simply CTR.   What puts more money in your pocket, an ad with a CTR of 10% and a eCPM of $75 or an ad with a CTR of 5% and a eCPM of $125?  I'll take the latter.

4.  This is an idea I took from Dan Thies and his post on split testing Adwords ads.

Once you've been through the preliminary tests, you should have an ad version that is a winner.  This becomes your control ad.  So far, it is your top money maker.  It may be difficult to top this ad's results, so you don't want to run it evenly along 3 or more new ad versions that aren't proven.  You'll want your control ad to display 50% of the time and probably even more.

Here is how I modified the code to work with my control ad.  I modified the rand function to give me a random number between 0 and 9 which yields 10 possibilities.  The first ad in my code is my test ad.  It only displays when the random number is 0, so it only has a 10% chance of displaying.

The last ad in the code is my control ad.  It will display anytime the random number is anything other than 0, so it has a 90% chance of displaying.

<?
srand(time());
$random = (rand()%9);

if($random == "0")
{
echo "<div style=\"float:right; padding: 10px 10px 0 0;\">\n";
echo "<script type=\"text/javascript\"><!--\n";
echo "google_ad_client = \"pub-XXXXXXXXXXX\";\n";
echo "/* 300x250, created 11/16/09 */\n";
echo "google_ad_slot = \"XXXXXXXXXXXXXXXX\";\n";
echo "google_ad_width = 300;\n";
echo "google_ad_height = 250;\n";
echo "//-->\n";
echo "</script>\n";
echo "<script type=\"text/javascript\"\n";
echo "src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n";
echo "</script>\n";
}

else
{
echo "<div style=\"float:left; padding: 10px 10px 0 0;\">\n";
echo "<script type=\"text/javascript\"><!--\n";
echo "google_ad_client = \"pub-XXXXXXXX\";\n";
echo "/* 300x250, created 11/18/09 */\n";
echo "google_ad_slot = \"XXXXXXXXXX\";\n";
echo "google_ad_width = 300;\n";
echo "google_ad_height = 250;\n";
echo "//-->\n";
echo "</script>\n";
echo "<script type=\"text/javascript\"\n";
echo "src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n";
echo "</script>\n";
}
?>
</div>

Let me know how your testing goes.  If you have any questions, just leave me a comment and I'll do my best to help you.

 

If you enjoyed this post, make sure you subscribe to my RSS feed!

 

 

Tags: , , ,

5 Responses to “Free Script For Split Testing Adsense Color, Size, and Placement”


  1. Dan Thies Says:

    Brent, this is brilliant – a way to split test Adsense without using the clunky Google Analytics connections… thanks for posting it.


  2. Brent Crouch Says:

    I just smiled because “The Dan Thies” said this was brilliant. Thanks for stopping by and commenting.


  3. Glenn R. Says:

    Good information here. This is really useful. You could probably charge $7 and make some money off of it. It definitely is less problematic than I’ve found Google Analytics to be.

    Thanks,
    GR


  4. Brent Crouch Says:

    @Glenn – I’m glad it helped you. I don’t want your money, but a link would be nice!

    😉


  5. Split-Testing Website Pages – 122% Increase in Conversion Says:

    […] I was at Brent Crouch’s blog (Brent is a great guy and a good friend of mine) looking for a free adsense split testing script that he offers, when I came across a more recent post he published. In this newer post he explained […]

Leave a Reply