Coming Soon! eBook: Blog the Pro way
Easy steps towards money making blog with minimum efforts.

Tuesday, July 5, 2011

Adsense ad within blogger post

It is fairly easy to show Ads above and below the posts in Blogger, but the most important place is in the middle of the post where the visitors pay the most attention when they scan through your post.The more people they your ads, the more are the chances they will click them.
The problem in blogger is that, you cannot place ads or any other script in the middle of the post neither using template nor by putting the javascript in the post. But the solution is by splitting the post into blocks. Which is done in pretty much in the same way like the read more hack before blogger introduced it themselves. The credit for creating this goes to DANIELE PERILLI.
To get this working on your blog just follow these simple steps-

  • Go to your Blogger Dashboard
  • Go to Design tab> edit HTML section
  • Check Expand Widget templates
  • Search for this code <data:post.body/>
  • Replace this code with the following code
<div expr:id='"aim1" + data:post.id'></div> <div style="clear:both; margin:10px 0">
    <!-- Your AdSense code here -->
</div> <div expr:id='"aim2" + data:post.id'>
    <data:post.body/>
</div> <script type="text/javascript"> var obj0=document.getElementById("aim1<data:post.id/>"); var obj1=document.getElementById("aim2<data:post.id/>"); var s=obj1.innerHTML; var r=s.search(/\x3C!-- adsense --\x3E/igm); if(r>0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+16);} </script>
  • Replace “YOUR ADS CODE” with adsense ad code after parsing it. Which can be done here – Postable
  • Now Save your template and you are done!
Now when creating your post-
  • Just before publishing the post go to the html section of post
  • Paste The following HTML comment just where you want your ads to be shown-
<!—Adsense -->
  • Publish your post and you are done!

No comments:

Post a Comment