How to put adsense anywhere in your blog post!
Friday, December 14, 2007 | Labels: Blogger Hacks | 1 comments |
It should look like this when it's done.
For new Blogger
Go to your template section, press edit html, check expand widget templates, hit ctrl-f and find "data:post.body", now replace that tag with the following code.
Replace "your adsense code" with your parsed adsense 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>
For old Blogger
Find the $BlogItemBody$ tag, and replace it with the following code.
<div id="prv<$BlogItemNumber$>"></div>
<div style="clear:both;margin:10px 0">
<!-- Your AdSense code -->
</div>
<div id="fst<$BlogItemNumber$>">
<$BlogItemBody$>
</div>
<script type="text/javascript">
var obj0=document.getElementById("prv<$BlogItemNumber$>");
var obj1=document.getElementById("fst<$BlogItemNumber$>");
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
Now in every blog post, simply type
<!-- adsense -->wherever you want adsense to appear.
Ps. Remember that google only allows 3 ad blocks per page. If you try to display more, it just won't show.
Have fun and good luck monetizing!