Advertisements

How to put AdSense in the Middle or Anywhere of Blogger posts

Posted by Lasantha Bandara on May 18th, 2009 File Under : adsense, html, post14 Comments
Advertisements

If you want to put Adsense ads in the middle of Blogger posts follow the steps below.

1.Generate Parsed code for your adsense code because we cannot put adsense code directly in the xml.So parse it using AdParser.

After parsing,your ad code Should look like this.

2.Log in to your dashboard--> layout- -> Edit HTML

3.Click on "Expand Widget Templates"

4.Scroll down to where you see this:


<data:post.body/>

5.Now replace above code with below 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 : You must you must replace <!-- Your AdSense code here --> with Your Adsense Parsed code.

6.Now save your template.

7.In every blog post ,Put this special code :


<!-- adsense -->

in the exact point you want to appear AdSense advertising.Now you are done.

File Under : adsense, html, post

14 Responses to “How to put AdSense in the Middle or Anywhere of Blogger posts”

  1. MhrLive says:

    cant do this for all my posts !!
    do you have any solution to put the ads after 5 or 6 lines of the post if it the post have > 5 lines automatically ?
    thanx

  2. Dav7 says:

    nice, I will try this on my following posts !

  3. vishal goyal says:

    Dear Its Not Working

  4. chaos09 says:

    on the homepage there is a gap between the post title and the body which is not good

  5. merzy-rider says:

    It's work on my blog. Please read the instruction carefully, maybe you missing something. By the way thanks for the trick.

  6. Putri Arisnawati says:

    thank you for your post.

  7. Moneyranger says:

    Thanks for help....I applied this on adhitz instead of adsense and wow it worked....Thanks a lot...
    You can check my blog www.learntoearnmoney.net.......now the ads are in middle of posts.... :-D

  8. Saimon says:

    Nice, Thanks For Share.

  9. vicky says:

    is was helpfull thanx http://mobilemillion.blogspot.com/

  10. Menti says:

    Thanks so much, i added to my site and its working perfectly

  11. shahbaz Khan says:

    Thanks For SHaring,its working,

  12. Swaroop says:

    I Applied this on My Blog http://www.cinema65.com and got a Intresing result.. Thank you :)

  13. Michael says:

    ups i guess i can not paste htlm code in here. I'll try like this: "data:post.body" - this is the code that appears 5 times in my code

  14. ardi santoso says:

    Thank you very much. It's work on my blog.

Leave a Reply