Today I will show you a trick which will allow you to place AdSense ads anywhere inside your blog post. Once Added you can place the ads anywhere in the post like after the first line of text, before the last line, in the middle.....and you can have the ads in different areas in every post.

This is not a plugin but just a little piece of code and script. Isn't that interesting? Well, if you think this is for you, continue reading this post.

Firsly, you need to parse your Adsense code so that it can be read by blogger script. To parse your adsense ads code, use our tool here. Now save the parsed Adsense code and keep it safe for later use.

Next:
Go to your template: in Blogger it will be
<data:post.body>


Now replace the above code with this:
<div expr:id='"aim1" + data:post.id'></div>
<div style="clear:both; margin:10px 0">
PUT YOUR PARSED 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>


Now include your AdSense code above were you see: PUT YOUR PARSED ADSENSE CODE HERE.
Now you can make the AdSense Ad appear in any part of your blog post. When you writing your post - Simply place the following piece of code in your post in the exact place you want the Ad to appear:

<!-- adsense -->


Float The AdSense Unit And Wrap In Text:
<div style="float: left; margin-right: 5px;">
<!-- adsense -->
</div>
That's it!

Post a Comment