Your Ad Here

Thursday, October 18, 2007

Embedding AdSense in your Blogger posts

For all of you Blogger users, and thanks to our friend Diego Parrilla's blog, I finally figured out how to embed Google Adsense units into blogger posts. And now you can see the beautiful result on the right of this very post.
I decided to share this with you, since I am sure that many blogger users had the same problem when trying to optimize their AdSense positionning in order to maximize their Click-Through Rates (CTR).
So here we go with the 5 simple steps to go through in order to realize this :

1. Go to your blog's template HTML code
2. Find the < div class="post-body"> tag
3. Paste your Google AdSense code as follows between that tag ( < div class="post-body"> ) and the < $BlogItemBody$ > tag : (change "right" to "left" as the float attribute if you prefer the Ads unit on the left side of the post)

< div style="float: right;">
[Google Adsense Code pasted from Google Adsense Setup]
< /div >

4. Insert the following script before the < div id="sidebar"> tag

< script type="text/javascript">
var nodes = document.getElementsByTagName('DIV');
var size = nodes.length;
for (var i = 0; (i<size); i++) {
if (nodes[i].style.clear=='both') {
if(nodes[i].parentNode.className=='post-body') {
nodes[i].style.clear='';
}
}
}
< /script >

5. You're done. Preview it before saving the template. If it's OK for you, save the changes and enjoy your new AdSense optimized blog.

--
Be the first to know through RSS Subscriptions :

Subscribe in a reader, or subscribe by email and read us in your inbox :

Enter your email address:

No comments: