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.

48 comments:

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

    ReplyDelete
  2. Nice info there. well done bro

    ReplyDelete
    Replies
    1. ogbonge, you dey here? lol

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

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

    ReplyDelete
  5. Off to my blog to implement this. Thanks bro

    ReplyDelete
  6. 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

    ReplyDelete
    Replies
    1. 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.

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

    ReplyDelete
  8. 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?

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

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

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

    ReplyDelete
    Replies
    1. 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.

      Delete
  11. Hello,

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

    Thanks

    ReplyDelete
    Replies
    1. i need the same process :(

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

      Delete
  12. i have two . Where can i paste the code.

    ReplyDelete
  13. Not workong :( help me

    ReplyDelete
  14. 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

    ReplyDelete
    Replies
    1. Anonymous6/07/2014

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

      Delete
    2. 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!

      Delete
    3. 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.

      Delete
  15. 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 :)

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

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

    ReplyDelete
  17. 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

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

    ReplyDelete
  19. How to show ads at the end of the post?

    ReplyDelete
  20. 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.

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

    ReplyDelete
  22. 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.

    ReplyDelete
    Replies
    1. 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.

      Delete
  23. thank you for help

    ReplyDelete
  24. what is reason? sometime my adsens show and sometime not show

    plz tell me

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

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

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

    ReplyDelete
  28. 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 :)

    ReplyDelete
  29. 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.

    ReplyDelete
  30. 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.

    ReplyDelete
  31. 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.

    ReplyDelete
  32. 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?

    ReplyDelete
  33. 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

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

    ReplyDelete

Although every comment is appreciated, due to an overwhelming amount of questions, I can no longer provide personalized help. Keep in mind that comments are moderated and may take some time to appear. All spam comments will be deleted. Thanks for understanding!