It's something very simple... I'm looking for a code that will display Ads 50% one code and 50% another. I find many similar JS scripts but they work on banners ads which in this case I'm looking to display AdSense code (2 deffrent ones) Does anyone know where can I find JS that does it ?
Just tested this out, and it worked fine. In order to split it 50/50, you can use a random number. Math.random() gives you a random value from 0 to 1, so if Math.rand() is greater than .5, display one ad, otherwise display the other. Then, you conditionally use either set of AdSense ad_slot, width, and height settings. <script type="text/javascript"><!-- google_ad_client = "pub-**************"; if (Math.random() > .5) { google_ad_slot = "5396010225"; google_ad_width = 250; google_ad_height = 250; } else { google_ad_slot = "3900536874"; google_ad_width = 250; google_ad_height = 250; } //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> HTML: Replace the ad_slot, ad_width, and ad_height values with the ones for your two different ad groups and it should work. Also make sure you insert your own publisher id. Good luck, - Walkere
Should work fine. Just move the line... google_ad_client = "pub-**************"; Code (markup): inside the conditional statement and you should be fine. - Walkere