How to Add Adsense Ads In the Middle or Anywhere inside Blogger Posts

In a previous post we saw how and where we can place Adsense ads on our blog; however, these methods would only work when we place the ads on predetermined and fixed locations. For posts area, the most common places are below the title, at the beginning of the post or at the end of the post.
adsense placement

But what if we want to display an AdSense ad in the middle of a post?

We can manipulate the location of the ads to be displayed by adding a script inside the template and using a tag inside our post to where we want the AdSense ad to appear. Once added, we can place the ads anywhere, be it between paragraphs or in the middle of the content etc.

Manually inserting Adsense ads in the middle of posts in Blogger is pretty simple, just follow these steps below:

Before proceeding, it is recommended do backup your template (go to Template > click on the Backup/restore button)

Step 1. First thing we need to do is to "parse" the AdSense code, in other words, convert it to plain text. Then go to Template, click on the Edit HTML button, click anywhere inside the code area and look for this tag (CTRL + F):
<data:post.body/>
Note: you may find it several times, but we need to stop at the second one or if you can't see any changes, test the third one

Screenshot
Step 2. Replace the <data:post.body/> tag with this code:
<div expr:id='"adsmiddle1" + data:post.id'></div>
<b:if cond='data:blog.pageType == "item"'>
<b:if cond='data:blog.pageType != &quot;static_page&quot;'>
<div style="clear:both; margin:10px 0">
<!-- Add here the code of your ad -->
</div>
</b:if>
</b:if>
<div expr:id='"adsmiddle2" + data:post.id'>
<data:post.body/>
</div>
<script type="text/javascript">
var obj0=document.getElementById("adsmiddle1<data:post.id/>");
var obj1=document.getElementById("adsmiddle2<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>
Step 3. Put the converted Adsense code to where you see the <!-- Add here the code of your ad --> annotation, then save the changes by clicking on the Save template button.

Note: For centering ads, add the center tag before and after the AdSense code, like this:
<div style="clear:both; margin:10px 0">
<center>
<!-- Add here the code of your ad -->
</center>
</div>
Step 4. When you create a New Post, add this tag inside the HTML section to where you want the Google AdSense ads to appear:
<!-- adsense -->
For example:
<div>This is a demo text. This is a demo text. This is a demo text. This is a demo text. This is a demo text. This is a demo text. This is a demo text. This is a demo text. This is a demo text. This is a demo text.</div>
<!-- adsense --><div>This is a demo text. This is a demo text. This is a demo text. This is a demo text. This is a demo text. This is a demo text. This is a demo text. This is a demo text. This is a demo text. This is a demo text.</div>

Screenshot
Note: If you don't add the label to bring up the ad, then the ad will appear below the title by default.

And you don't have to worry about violating the Google's Terms of Service because applying this method we are not changing the structure of the ad.

Comments/disqusion
48 comments

  1. says:

    Can you tell how to show ads at the end of the post i.e. between post and comments ?

  2. says:

    Nice info there. well done bro

  3. says:

    Superb Bro..! Excellent blog..! Hats off to you.

  4. says:

    Sir, please email me your blogger template. My email .

  5. says:

    Off to my blog to implement this. Thanks bro

  6. says:

    ogbonge, you dey here? lol

  7. says:

    it work before in my blog, but today my ads not show after title, ... i restore my blog previous date and again try this trick but i failure :( what happen pls help sir

  8. says:

    Hi Ahad,

    Please make sure that you include the adsense tag in the HTML of your post to where you want it to appear. You need to add this tag each time you create a new post.

  9. says:

    Weirdly I just cant get this thing to work! haha, I am sure theres something i'm overseeing.

  10. says:

    For some reason my ad's are just showing up white within the post, but are working throughout my template elsewhere? has anyone else experienced this?

  11. says:

    admin can i insert more than one ads by placing the tag in diffrent parts of the post?

  12. says:

    I think it is ok as long as you have rich content, just make sure that you don't make them look too cluttered.

  13. says:

    admin i have a problem even if i add the tag the ad is showing up only below the title

  14. says:

    Hello,

    Is there a way I can align the ad to the center?

    Thanks

  15. says:

    i have two . Where can i paste the code.

  16. says:

    Not workong :( help me

  17. says:

    i need the same process :(

  18. says:

    i follow your procedure ads shows.but the problem is it appears inside every post on home page of blog.On home page i set 5 posts and it is showing inside every post on home page.so its total 6 posts on 6 ads showing on home page.which violate adsense policy

  19. says:

    I have the same problem. If there is a fix for this it will be great.

  20. says:

    Hi there,

    You will need to add some conditional tags to the adsense code in order to hide it on homepage. Here's a tutorial that will show you how to hide scripts or widgets in homepage or post pages. Thanks for visiting!

  21. says:

    I've updated my post so you don't have to add any conditional tags, just replace the older code with the one from step 2.

  22. says:

    Dear Sir, I have applied this trick and it work very well for me... I have successfully google ad after the Title.
    Now, I want to know How you put google ad .. at end of your post ... before the comment box?
    when i try from blog option, my google ad visible after the comment box. but I want to put google ads before the comment box and end of the post. Same like yours

    if possible can you share this trick with me. Thankful to you :)

  23. says:

    Bro please help me please, my even through this trick my ads were not showing any way inside the post

  24. says:

    Me too :(

  25. says:

    putting adsense in every post i hope we are not violating the terms and condition on adsense! please give me explanation in this, actually we all want to know this

  26. says:

    Thanks. I implemented this on my blog. www.jaizelden.com

  27. says:

    How to show ads at the end of the post?

  28. says:

    It works, but how to put two ads in the same post? I tried to add code twice, but it only shows one ad on page.

  29. says:

    Works, thanks! Wondering if there's a way to make it default to the BOTTOM, because it's butt-ugly up at the top. :-)

  30. says:

    Hi everyone,

    I placed the google adsense within the empty box to convert it to plain text. That is done now, where will I put these converted codes?

    Need help and thanks in advance.

  31. says:

    thank you for help

  32. says:

    what is reason? sometime my adsens show and sometime not show

    plz tell me

  33. says:

    I would also like to know this!

  34. says:

    Yes, as he says, just place the ad code between the center and /center tags.

  35. says:

    I am looking for the same thing - to have the default be at the END of the post, not at the beginning.

  36. says:

    Marina: you will have to find the data:post.body tag (the second one, as he says) and then paste in the entire code chunk, not just your ad code.

  37. says:

    This was happening for me until I found and replaced the SECOND data:post.body. I had skipped the instruction to keep searching until I found that one. So try restoring your template (you did back it up, right?) and then changing the second tag, not the first.

  38. says:

    hi , even after successfully adding and saving code , ads wont display
    i use premium template . please visit http://www.kareducation.in/ and help me

  39. says:

    NOT WORKING

  40. says:

    how add lightbox effect in images blogger...look like yours ?? and thank u

  41. says:

    Hello Admin,
    can you please tell me how to add Adsense code to Home page in Wordpress?
    Thanks

  42. says:

    This is one of a haluwa post1 Seriously, i was searching for so long for this type of ad placement, but was not able to insert the ads inside a post. And, Blogger Adsense widget is useless. I think, they are too busy to look at this. Otherwise thoy could have easily provided that support via in-built theme coding. That's where the people like you come to our rescue. Long live the writer of this post :)

  43. says:

    Ads are not showing in mobile version. Any solution for this? When I open html source of mobile page, I only see instead of adsense code, like I see it on desktop version.

  44. says:

    Hi,
    Firstly I would like you to thanks you for this.
    I saw in your post there are two adsense ads are showing in your post, i would like to use this too.
    Can you tell me how to display 2 ads inside post.

    Thanks in advance.

  45. says:

    This code works great, and I have it on all my blogs. However, I've discovered that it doesn't play nicely with Rafflecopter. Keeping this code; have to find an alternative for contests etc. Just thought I'd report this, in case anyone else is having trouble.

  46. says:

    i have strange problem in my blog, after 200 comments, new comments are not loading after clicking on 'load more comments' how to solve it?

  47. says:

    when i open edit html page in layout and search for the word u told for data post body it doesnt show any codelike this anywhere in that html edit page \thans help me to add ads in my blog thanks

  48. says:

    Hi Admin, this sign did not allowing me to save it, should i remove it or what should i do