How to Put AdSense Inside Blogger Post – Advanced Practices

Google AdSense is the best way to earn revenue through your blog. For this purpose, placing ads in the right place where coverage is maximum is very important. In this post, we will discuss advanced practices to display ads in the right places to generate high revenue from your blog and give worth to your writing skills. There are two places in a post with high coverage of an ad unit. Coverage of ad units means clear visibility to readers and more chances of getting clicks. One of the most prominent positions is just below the post title/start of the post, and the other is in the middle of the post. In this article, we will also discuss how to put AdSense inside Blogger posts only. Ads on the Blogger Static Pages will not appear.

Put Google AdSense in middle of post

The most recent version here –

Display AdSense Inside Blogger Post Automatically

Hereunder is a script that will show ads automatically at the start and middle of the post. This script finds the middle part of the blog post and automatically places an ad. It will not work perfectly for some blogs, like tech blogs, where HTML code sharing is common. It might come between shared code. But on all other blogs, it will work perfectly.

This code is also for those using scripts to show the post excerpt on their home page.

CASE-I: For those who are using post excerpts on the home page.

  • To use this script, go to theme HTML,
  • Search for <data:post.body/>
  • Replace this code with the following code
  • Finally, hit the Save button.

CASE-II: For those using the default Blogger theme, i.e., no post excerpt on the home page.

  • To use this script, go to theme HTML
  • Search for <data:post.body/>
  • Replace this code with the following code
<b:if cond='data:blog.pageType == &quot;index&quot;'>
<data:post.body/>
</b:if>
  • Now paste the following code just above it, and hit the save button.
<!-- Ads in mid of post: automatically -->
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<div expr:id='"atmid" + data:post.id'/>
<div style="clear:both; margin:10px 0;text-align:center">
<!-- Paste Ad code here: Appear at mid of the post -->
</div>
<div expr:id='"attop" + data:post.id'>
<div style="clear:both; margin:10px 0;text-align:center">
<!-- Paste Ad code here: Appear at top of the post -->
</div>
<data:post.body/>
<div style="clear:both; margin:10px 0;text-align:center">
<!-- Paste Ad code here: Appear at bottom of the post -->
</div>
</div>
</b:if>

<script type="text/javascript">
var obj0=document.getElementById("atmid<data:post.id/>");
var obj1=document.getElementById("attop<data:post.id/>");
var s=obj1.innerHTML;
var t=s.substr(0,s.length/2);
var r=t.lastIndexOf(" ");
if(r>0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+1);}
</script>
<!-- Ads in mid of post: automatically -->

If you want to display ads on specific posts, you can use post labels to control ad visibility. The following script may work for you.

  • To use this script, go to theme HTML
  • Search for <data:post.body/>
  • Replace this code with the following code
  • Last, save the changes.
<!-- Ads in mid of post: automatically -->
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<div expr:id='"atmid" + data:post.id'/>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.name == &quot;Label-Name&quot;'>
<div style="clear:both; margin:10px 0;text-align:center">
<!-- Paste Ad code here: Appear at mid of the post -->
</div>
</b:if>
</b:loop>
<div expr:id='"attop" + data:post.id'>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.name == &quot;Label-Name&quot;'>
<div style="clear:both; margin:10px 0;text-align:center">
<!-- Paste Ad code here: Appear at top of the post -->
</div>
</b:if>
</b:loop>
<data:post.body/>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.name == &quot;Label-Name&quot;'>
<div style="clear:both; margin:10px 0;text-align:center">
<!-- Paste Ad code here: Appear at bottom of the post -->
</div>
</b:if>
</b:loop>
</div>
</b:if>

<script type="text/javascript">
var obj0=document.getElementById("atmid<data:post.id/>");
var obj1=document.getElementById("attop<data:post.id/>");
var s=obj1.innerHTML;
var t=s.substr(0,s.length/2);
var r=t.lastIndexOf(" ");
if(r>0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+1);}
</script>
<!-- Ads in mid of post: automatically -->

Notes –

  1. You can use three different labels for three different ads at the top, mid, and bottom of the post. You must change the value Label-Name with the actual Label of your post.
  2.  You must change the following three values with your three different/same ad codes.

<!– Paste Ad code here: Appear at the top of the post –>
<!– Paste Ad code here: Appear at the middle of the post –>
<!– Paste Ad code here: Appear at the bottom of the post –>

Put AdSense in the Middle of Blogger Post

If you want to place an ad at the custom location in between posts, there is also a solution for you. You have to place <– ads –> tag where you want to show the ad, i.e., at the custom location in between your every post.

  • To use this script, go to theme HTML
  • Search for <data:post.body/>
  • Replace this code with the following code
  • Lastly, Save the changes.
<!-- Ads in mid of post: automatically -->
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<div expr:id='"atmid" + data:post.id'/>
<div style="clear:both; margin:10px 0;text-align:center">
<!-- Paste Ad code here: Appear at mid of the post -->
</div>
<div expr:id='"attop" + data:post.id'>
<div style="clear:both; margin:10px 0;text-align:center">
<!-- Paste Ad code here: Appear at top of the post -->
</div>
<data:post.body/>
<div style="clear:both; margin:10px 0;text-align:center">
<!-- Paste Ad code here: Appear at bottom of the post -->
</div>
</div>
</b:if>

<script type="text/javascript">
var obj0=document.getElementById("atmid<data:post.id/>");
var obj1=document.getElementById("attop<data:post.id/>");
var s=obj1.innerHTML;
var r=s.search(/x3C!-- ads --x3E/igm);
if(r&gt;0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+13);}
</script>
<!-- Ads in mid of post: automatically -->

As I explained above, if you want to display ads on certain posts, you can use post labels to control ad visibility. The following script may work for you.

There is also a solution if you want to place an ad at the custom location between posts. You must place <– ads –> tag where you want to show the AdSense inside the Blogger post.

  • To use this script, go to Theme HTML
  • Search for <data:post.body/>
  • Replace this code with the following code
  • Finally, Save the changes.
<!-- Ads in mid of post: automatically -->
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<div expr:id='"atmid" + data:post.id'/>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.name == &quot;Label-Name&quot;'>
<div style="clear:both; margin:10px 0;text-align:center">
<!-- Paste Ad code here: Appear at mid of the post -->
</div>
</b:if>
</b:loop>
<div expr:id='"attop" + data:post.id'>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.name == &quot;Label-Name&quot;'>
<div style="clear:both; margin:10px 0;text-align:center">
<!-- Paste Ad code here: Appear at top of the post -->
</div>
</b:if>
</b:loop>
<data:post.body/>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.name == &quot;Label-Name&quot;'>
<div style="clear:both; margin:10px 0;text-align:center">
<!-- Paste Ad code here: Appear at bottom of the post -->
</div>
</b:if>
</b:loop>
</div>
</b:if>

<script type="text/javascript">
var obj0=document.getElementById("atmid<data:post.id/>");
var obj1=document.getElementById("attop<data:post.id/>");
var s=obj1.innerHTML;
var r=s.search(/x3C!-- ads --x3E/igm);
if(r&gt;0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+13);}
</script>
<!-- Ads in mid of post: automatically -->

Notes –
1. You can use three different labels for three different ads at the top, mid, and bottom of the post. You must change the value Label-Name with the actual Label of your post.
2. You Must change the following three values with your three different/same ad codes.

<!– Paste Ad code here: Appear at the top of the post –>
<!– Paste Ad code here: Appear at the middle of the post –>
<!– Paste Ad code here: Appear at the bottom of the post –>

3. Add <– ads –> tag tag in each post in HTML mode.

Important: Before adding/injecting AdSense or other ad codes in a Blogger theme, you must Parse it; otherwise, it will not appear in the posts. To parse AdSense code, you can use our AdSense code parser code.

The most recent version here –

References:
1. http://www.o-om.com/2013/06/menampilkan-iklan-ditengah-posting-berdasarkan-label.html

Still, comment or open a topic in our forum if you have doubts.

25 thoughts on “How to Put AdSense Inside Blogger Post – Advanced Practices”

  1. Hi, I was fed up with the issue, but your article really helpful. I injected your codes in my blog and it works perfectly, but after one day I came to know that, there is some problme with ads which is coming in the middle of the post. my ads showing with html codes like ( style=”font-family: “georgia” , “times new roman” , serif;”> ) its appearing on main screen, please help me to fix that.There is no problem with upper and bottom ads

  2. Nice article but the ads in midpost is not working properly, show some html code, I will appreciate if you fix it

  3. Hello, the location of the ads works correctly but I have the same problem of JEKKO JOY that after the first ad all the text changes and there is no way to return to the original style and size.

  4. it is working but my blog page’s contents not visible after add that code. How to fix it?

  5. Avatar photo
    Swetabh Suman

    Hello, thanks for writing on this and it is working perfectly but I there are some issue like if you add this code to the HTML Blog Editor then your Blog Pages will not work. I am saying only about pages, not posts.

    Let me know if you find any solution. I tried everything but not working.

  6. Thank you for any other fantastic article. The place else may anyone get that kind of information in such an ideal approach of writing?

    I have a presentation next week, and I am at the search for
    such info.

  7. waoo great article but the ads in midpost is not working properly, show some html code, I will appreciate if you fix it plzz help

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top