The solution to this problem is quite simple: you only need to move the post body around the advertising code, just with a bunch of JavaScript and a couple of DIVs (divisions).
Works For both Old blogger and New Blogger.
1. In your Blogger template:
OLD BLOGGER
Find the tag <$BlogItemBody$> and replace it with 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>
NEW BLOGGER
Find the tag <data:post.body/> (you must check Expand Widget Templates in Blogger console) and replace it with 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>
Note that you must replace <!-- Your AdSense code --> with block code provided by Google.
2. In every blog post:
Put a special comment
<!-- adsense -->in the exact point you want to appear AdSense advertising.
Done!
Questions
- Does this method violate Google ToS?
No. Answering a direct support request Google stated this method doesn't violate any of their program policies. - What if I forget to put in a post the <!-- adsense --> comment?
Nothing. The advertising block will appear in the traditional position you defined in your template before implementing this modification. - What happens in Blogger home page and archive pages where there several posts with <!-- adsense --> comment appears together?
Exactly the same thing happening before this modification: Google automatically inject in your posts up to 3 AdSense blocks. So just the first 3 posts (in a top-down order) in your home page or archive pages will have ads.

it gives me a blank space above my every post
ReplyDeleteAnonymous that space is for ads....there is nothing wrong with that.
ReplyDeleteTry and let me know if it was successful for you
Wow thats great.
ReplyDeleteHi I have the same space problem.. ads never show up... ever?
ReplyDeletePlease contact me at curiousread [at] gmail.com
thanks