Source: http://adsense.blogspot.com/2006/08/abcs-of-ab-testing.html <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> Code (markup):
This can also be done with PHP, but the advantage of the JavaScript version is that you'll still get a random ad even if it's been cached, where as the PHP output will only change if it's regenerated by the server. Thanks minstrel - good find.
here's the PHP version. http://www.justin-cook.com/wp/2006/04/19/displaying-and-tracking-multiple-random-adsense-formats/ the advantage to using PHP is less info that needs to be sent to the client, and no extra JavaScript processing needed
Thanks for sharing minstreal and frankcow I found while ago an ASP version but it didn't work, and obviously either in those sites hosted on Linux servers