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:
- replace all " with \"
- end each line with \n
- replace /script with \/script
<script type="text/javascript">
var i = Math.random()
var googlead = PASTE ADSENSE AD HEREvar i = Math.random()
var yahooad = PASTE YPN-CONTENTMATCH AD HERE
if (i < 0.5){
document.write(googlead);
}
else
{
document.write(yahooad);
}
</script>
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 ):
var googlead = "
var yahooad = "
<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"
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"
<!--\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:
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.
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!
Post a Comment