Posted By

blazonry on 03/23/11


Tagged

test adsense ab


Versions (?)

A/B Test Google AdSense Ads


 / Published in: PHP
 

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

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

  1. <?php
  2.  
  3. srand(time());
  4. $random = (rand()%2);
  5.  
  6. if($random == 1)
  7. // run one format ad using your ad code (format a)
  8. {
  9. ?>
  10.  
  11. <script type="text/javascript"><!--
  12. google_ad_client = "pub-xxxxxx";
  13. google_ad_slot = "xxxx";
  14. google_ad_width = 336;
  15. google_ad_height = 280;
  16. //-->
  17. </script>
  18. <script type="text/javascript"
  19. src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  20. </script>
  21.  
  22. <?php
  23. }
  24. else
  25. // run other format ad (format b)
  26. {
  27. ?>
  28.  
  29. <script type="text/javascript"><!--
  30. google_ad_client = "pub-xxxx";
  31. google_ad_slot = "xxxxx";
  32. google_ad_width = 250;
  33. google_ad_height = 250;
  34. //-->
  35. </script>
  36. <script type="text/javascript"
  37. src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  38. </script>
  39.  
  40. <?php
  41. }
  42. ?>

Report this snippet  

You need to login to post a comment.