Ok this topic has been done before but I still had trouble with it so I decided to make some notes on my Adsense blog in hopes of simplifying the process and maintaining it for myself in the future. If you want to do some split testing of your Adsense ad blocks ( Commonly called A/B testing). You’ll need to first create two ad blocks with a unique channel assigned to each. I am usually testing differen’t sizes like a 300×250 vs 468×60 so I name my Adsense channels with 300 after one and 468 after the other, or you could use red or blue if you were testing colors etc. So now that you have the code for your two ad blocks paste both into Notepad so you can work with them. Now take this code and paste it into your website or blog where you want the ad block to appear.
<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>
<script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”></script>
Ok now the tricky part. Where it says “//your second ad unit code goes here” or “//your first ad unit coes here” remove that and replace it with the INSIDE of your Google Adsense ad block. Here’s my code below. Notice I only included the code that starts with that is the tricky part. So the part I inserted from my code is in red. Enjoy your testing.
