Blogger

How to place Adsense Ads in Every Blogger Post Automatically

We work hard to write an article, but we can’t make it even harder by placing Ads code one by one on every Blogger blog post. This tutorial will discuss, How to insert every kind of AdSense ad or other platform ads into the middle of every Blogger blog post? Follow the steps provided below.

Insert Adsense ads code automatically in the Middle of every Blogger post

We can easily implement Adsense Ad code to show ads in the middle of every Post. For this, use “text and image“, “text-only ads“, or a new type of Native Ads, “In-Article Ads”.

If you’re looking to place AdSense ads automatically in the Blogger feed, refer our this article to set up In-feed ads for Blogger.

insert-adsense-ads-in-every-blog-post-blogger-automatically
Place AdSense Ads in Blogger Post Automatically

How to implement Adsense ads automatically in the Blogger posts?

Google introduced new kinds of native ads for its publishers to increase revenue and a good user experience. According to Google, these native kinds of ads can increase AdSense revenue by 60%. But as per our experience, we’ll advise placing “Text and Image” type of AdSense Ads for better results.

But here, you can add any ad unit using our code provided below to implement ads in the middle of a Blogger blog. Just copy the provided code, change ad unit values and place it as suggested in this article.

Step by Step guide.

1. Insert AdSense ads code in every Blogger post automatically, using XML code.

By implementing the code provided below into your Blogger theme file, you can show AdSense ads on every Blogger post. For this, you need to edit the Blogger Theme.

<b:if cond='data:view.isPost'>
<div id='seoneurons-target'>
 <data:post.body/>
</div>
<div id='seoneurons-content'>
<div style='margin:15px 0;text-align:center;clear:both;'>
      <!--Place Your Prased Adsense Ad code here-->
</div>
 </div>
<div id='seoneurons-target'>
 <script type='text/javascript'>
function insertAfter(addition,target) {
var parent = target.parentNode;
if (parent.lastChild == target) {
parent.appendChild(addition); 
} else {
parent.insertBefore(addition,target.nextSibling);
}
}
var adscont = document.getElementById("seoneurons-content");
var target = document.getElementById("seoneurons-target");
var linebreak = target.getElementsByTagName("br");
if (linebreak.length > 0){
insertAfter(adscont,linebreak[2]);
}
</script>

</div>
</b:if>
 <b:if cond='data:view.isPage'><data:post.body/></b:if>
  1. Copy Above Code and Paste it in Notepad or any text editor application.
  2. Open the Google Adsense Account
  3. Generate Adsense Ads or any ads(Text and Image) code
  4. Now Prase Ad code —Click here to Prase Your code
  5. Replace line <!–Place Your Prased Adsense Ad code here–> with your Prased Adsense Code generated in step 4.
  6. Now Open blogger.com and select “Theme”.
  7. Download the theme file for backup.
  8. Now click on “Edit HTML”.
  9. Now you’ll see XML of your blog.
  10. And Now search <data:post.body/>. If you cannot find it, copy the whole file and edit it externally using any text editor.
  11. Replace <data:post.body/> with the above code(created in Notepad).

Note: In the latest Blogger theme, there is only one <data:post.body/> tag, but if you’re using older themes, there maybe 2 or 3 or more result for <data:post.body/>. In such an old version of the theme, you’ve to make hit and the trial method by checking all <data:post.body/>. In most of the templates, it works on 3rd result of <data:post.body/>.

Changes to be made are:

  • Replace “**YOUR PRASED AD CODES**” with your own ads code.
  • This code you replaced will appear in the middle of Blogger Blog as an Adsense ad.
  • The Adsense Ads will place after the 2nd Paragraph of the Blogger post,

2. Place Multiple Adsense ads Automatically in Every Post of Blogger

And If you want to place more than one Adsense Ads in between the multiple paragraphs of the Blogger post, Replace the code given below instead of the previous code.

<b:if cond='data:view.isPost'>
<div id='seoneurons-target'>
 <data:post.body/>
</div>
<div id='seoneurons-content1'>
<div style='margin:15px 0;text-align:center;clear:both;'>
      <!--Place Your 1st Prased Adsense Ad code here-->
</div>  
 </div>
 <div id='seoneurons-content2'>
<div style='margin:15px 0;text-align:center;clear:both;'>
      <!--Place Your 2nd Prased Adsense Ad code here-->
</div>  
 </div>
<div id='seoneurons-target'>
 <script type='text/javascript'>
function insertAfter(addition,target) {
var parent = target.parentNode;
if (parent.lastChild == target) {
parent.appendChild(addition); 
} else {
parent.insertBefore(addition,target.nextSibling);
}
}
var adscont = document.getElementById("seoneurons-content1");
var target = document.getElementById("seoneurons-target");
var linebreak = target.getElementsByTagName("br");
if (linebreak.length > 0){
insertAfter(adscont,linebreak[1]);
}
</script>
     <script type='text/javascript'>
function insertAfter(addition,target) {
var parent = target.parentNode;
if (parent.lastChild == target) {
parent.appendChild(addition); 
} else {
parent.insertBefore(addition,target.nextSibling);
}
}
var adscont = document.getElementById("seoneurons-content2");
var target = document.getElementById("seoneurons-target");
var linebreak = target.getElementsByTagName("br");
if (linebreak.length > 0){
insertAfter(adscont,linebreak[3]);
}
</script>

</div>
</b:if>
<b:if cond='data:view.isPage'><data:post.body/></b:if>

Place the two different AdSense ads in the <!–Place Your Prased Adsense Ad code here–>. We recommend you to place a max of 2 ads if your article is 600 words longs. If you place a higher number of ads, then invalid clicks may increase and lower the CPC you get. That is completely a wrong practice.

target.getElementsByTagName("br"); Declares the ads’ location. Here to default tag for Blogger post is br for the break <br>. You can change it to p, h2, h3, h4 according to the need. If you don’t know what this is, then leave it as it is.

insertAfter(adscont,linebreak[n]); Declared how many tags the ads should be visible. Where n=number of tags-1, i.e., for 4 tags, n will be 4-1=3.

  • So if you want to display after 1 line break, then place 0 instead of 3,
  • to display an ad after 2 tags, then place 1 instead of 3,
  • and so on.

Our aim to increase the revenue of a website or blog. For this focus on writing an SEO Friendly article, that leads to result in high CPC.

If you find the above article helpful, or any doubt ask in the comment section below. We’ll be happy to help you. Thank you.

Ashok Kumar

Ashok Kumar working in the Search Engine Optimization field since 2015. And worked on many successful projects since then. He shares the real-life experience of best SEO practices with his followers on seoneurons.com. You also can learn Advance level SEO for WordPress, Blogger, or any other blogging platform. Stay tuned.

Related Articles

24 Comments

  1. Hello Dealsyou, you can create

    below

    and copy paste new script below last script, and make this changes in new script line = var adscont = document.getElementById(“techaak-content2”);
    in place of techaak-content2, place techaak-content3
  2. Hello Dealsyou, you can create <div id="techaak-content3"> below
    <div id="techaak-content2">
    and copy paste new script below last script, and make this changes in new script line = var adscont = document.getElementById("techaak-content2");
    in place of techaak-content2, place techaak-content3

  3. I am very grateful for you as a searched alot and i didn’t find any effective way till i found that post. Thanks alot

  4. Hello ashok sir very nice it’s working very well. But can you tell me if I want to place the ads after 3rd and 4th paragraph then what change I need to do in code. Please paste a new edited code in reply thank u…

  5. It is showing
    org.xml.sax.SAXParseException; lineNumber: 2520; columnNumber: 6; Element type “b:if” must be followed by either attribute specifications, “>” or “/>”.

    When I add your code into my blogger themes. Please help me

      1. I tried and copy all code and do it perfectly but it is showing

        org.xml.sax.SAXParseException; lineNumber: 2522; columnNumber: 5; Element type “div” must be followed by either attribute specifications, “>” or “/>”.

        What should I do now? I am trying to add multiple ads in between my posts.

          1. let me tell you that my theme is colored minima 3 theme. Does your code work in my theme? please let me know your email

Leave a Reply

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

Back to top button