Friday, August 3, 2007

How to Add Google Adsense Ad Units in Blogger Blog Posts

google-adsense-blogger-issues

DI reader Nauzer Elavia is facing problems while trying to integrate the Google Referral Adsense text links in the middle of his Blogger blog posts. [this is also applicable for standard Google Ads]

If I put any JavaScript code for Adsense (including referrals), either the ads don't turn up or just the raw Adsense code turns up or some other than Google Ads is displayed instead of the referral link units.

This is a very common problem when you try to mix Google Adsense code with your blog posts. The simple solution is to remove all the line-breaks from your Adsense code.

Here's an example using the Adsense referral code for downloading Firefox with Google Toolbar:

BEFORE (the code generated by Adsense Control Panel):

adsense-before

If you copy-paste the code as such in your blog editor, it will turn up as a blank area on your blog. If you look at the HTML source, you'll see that the line break <br> tag has been appended after each line cause the Adsense Javscript to break.

AFTER (remove the comments tag and all the line breaks after ";" and ">" by hitting the "DEL" key)

adsense-after

With the above changes, your Google Ads will appear as expected inside your blog posts.

Warning - do check the Adsense Program Policies. The Adsense rule book says that "Any AdSense code must be pasted directly into webpages without modification." So you may want to check with your Adsense rep if they are OK with the above changes. They may agree to your requests if you a valid case. For instance - split A/B testing.

Related: Suppress the JavaScript Warning in Blogger

0 comments:

Post a Comment