Some time ago, I wrote about a way to randomize ads; that is, in a particular position, show one of a number of different ads. With AdSense channels, you can use it to find out which ads (formats, colors, etc.) work better in a particular position.
But now I’m going to take you one step further.
What about randomizing between two positions? Say you want to see if an ad works better on the top or on the bottom of a page. How to show one, and only one of them?
Making the first ad show 50% of the time is easy. The problem, here, is that the second ad must have a way to tell whether the first ad was shown or not.
There are, of course, several ways, most of which using some kind of variable to store if the first ad appeared or not. But I think that there’s a better method, which has the advantage of being incredibly simple, and doesn’t require you to store anything.
It’s simple: use the clock.
If the current hour is even, you show one of the ads. If it’s odd, you show the other. Each of them “knows” whether it should appear or not, according to the current time.
Sounds complicated? It isn’t. For instance, using PHP, in the first position you put:
function isodd($number) { return($number & 1); }
$x = date('G');
if (isodd($x)) include "adsense-top.php";
And in the second position:
function isodd($number) { return($number & 1); }
$x = date('G');
if (!isodd($x)) include "adsense-bottom.php";
The “adsense-top.php” and “adsense-bottom.php” files can be mere AdSense code, or can branch itself further, using something like my original tip.
By the way, I use hours instead of minutes (which would provide better granularity) because I want to avoid, as much as possible, the small possibility of the hour changing in the miliseconds between the two scripts. Using the hour value, it should virtually never happen (never happened to me, so far), though it wouldn’t be the end of the world anyway.

