Return to Snippet

Revision: 43396
at March 23, 2011 07:43 by blazonry


Initial Code
<?php

   srand(time());
   $random = (rand()%2);

   if($random == 1)  
   // run one format ad using your ad code (format a)
   {
?>

   <script type="text/javascript"><!--
   google_ad_client = "pub-xxxxxx";
   google_ad_slot = "xxxx";
   google_ad_width = 336;
   google_ad_height = 280;
   //-->
   </script>
   <script type="text/javascript"
   src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
   </script>

<?php
   }
   else
   // run other format ad (format b)
   {
?>

   <script type="text/javascript"><!--
   google_ad_client = "pub-xxxx";
   google_ad_slot = "xxxxx";
   google_ad_width = 250;
   google_ad_height = 250;
   //-->
   </script>
   <script type="text/javascript"
   src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
   </script>

<?php
   }
?>

Initial URL
http://blazonry.com/php/adtest2.php

Initial Description
Quickly test different Google AdSense ads simultaneously and start getting side-by-side results the same day.  Use to identify which ads result in better revenue and higher click-thrus.  More detailed explanation at http://blazonry.com/php/adtest2.php

Initial Title
A/B Test Google AdSense Ads

Initial Tags


Initial Language
PHP