Moving To a New Site

I have just decided that it's time to move on and have my own domain. All the posts in this blog will be moved to:

www.pinoygeek.org

Personal posts will be transferred to: raldz.pinoygeek.org

Tuesday, October 18, 2005

Using JavaScript to Rotate Google Adsense and YPN ContentMatch Ads

By: Amr Awadallah

I wanted to test the performance of Adsense versus YPN-Content match on my site, so I wrote this little javascript wrapper to rotate both ad formats, 50% of the time for Google Adsense and 50% of the time for Yahoo-YPN-ContentMatch.


Feel free to use it, but note that you need to paste your ads in the correct places as demonstrated below. Just copy the javascript code for adsense and ypn ads and put them in the googlead and the yahooad variables, respectively. But make sure to make these changes to the javascript ads:



  1. replace all " with \"
  2. end each line with \n
  3. replace /script with \/script


<script type="text/javascript">

var i = Math.random()
var googlead = PASTE ADSENSE AD HERE
var yahooad = PASTE YPN-CONTENTMATCH AD HERE
if (i < 0.5)
{
document.write(googlead);
}

else
{
document.write(yahooad);
}
</script>


This is an example of how to paste your ad javascripts correctly into the googlead and yahooad variables (do not use these as is, otherwise you will end up sending me money Image ):



var googlead = "
<script type=\"text/javascript\"><!--\n
google_ad_client = \"pub-1023215734600446\";\n
google_ad_width = 728;\n
google_ad_height = 90;\n
google_ad_format = \"728x90_as\";\n
google_ad_type = \"text\";\n
google_ad_channel =\"3618420306\";\n
google_color_border = \"CCCCCC\";\n
google_color_bg = \"FFFFFF\";\n
google_color_link = \"000000\";\n
google_color_url = \"666666\";\n
google_color_text = \"333333\";\n
//--><\/script>\n
<script type=\"text/javascript\"\n
src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">\n
<\/script>\n"


var yahooad = "
<script language=\"JavaScript\">\n
<!--\nctxt_ad_partner = '2432839150';\n
ctxt_ad_section = '1181';\n
ctxt_ad_bg = '';\n
ctxt_ad_width = 728;\n
ctxt_ad_height = 90;\n
ctxt_ad_bc = 'A1A5A9';\n
ctxt_ad_cc = 'FFFFFF';\n
ctxt_ad_lc = '0000DE';\n
ctxt_ad_tc = '737374';\n
ctxt_ad_uc = '439341';\n
// -->\n
<\/script>\n
<script language=\"JavaScript\"\n
src=\"http://ypn-js.overture.com/partner/js/ypn.js\">\n
<\/script>\n"

2 comments:

Author : said...

This is Really a very useful piece of code which will prove beneficial to all the Bloggers who earn living from Ads.

All Best wishes.

Arya,
http://infotainmentcenter.com
LifeStyle,World.Travel,BusinessPlex,Finance,News,Matrimony.

Anonymous said...

it never occurred to me this idea of using JavaScript to rotate Google Adsense and YPN ContentMatch Ads and it's a great idea indeed, I was trying with Sildenafil Citrate ,but it did not work!