We work hard to write an article, but we can’t make it even more challenging by placing Ads code one by one on every Blogger blog post. This tutorial will discuss, How to automatically add AdSense ads into the middle of every Blogger blog post? Follow the steps provided below.

Implementing AdSense Ad Code to Every Blog Post.

It is very tough and time-consuming to pick an AdSense Ad code from AdSense and add it to every blog post. Sometimes we may forget to add the codes. This leads to a loss in revenue. Its solution is to add the AdSense ads code once and relax. Your AdSense ads code will insert in every blog post automatically.

We can quickly implement Adsense Ad code to show ads in the middle of every post. For this, use text and image, or a new type of Native, 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

Google introduced new native ads for its publishers to increase revenue and a good user experience. According to Google, these native 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 below to implement ads in the middle of a Blogger blog. Copy the provided code, change ad unit values, and place it as suggested in this article.

1. Insert AdSense Ad in Blogger Blog Post Automatically.

You can show AdSense ads on every blogger post by implementing the code below into your Blogger theme file. 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 the above code and paste it into Notepad or any text editor application.
  2. Open the Google Adsense Account
  3. Generate Adsense Ads or any ads(Text and Image) code.
  4. Replace line <!–Place Your Prased Adsense Ad code here–> with the Adsense code.
  5. Now Open blogger.com and select “Theme”.
  6. Download the theme file for backup.
  7. Now click on “Edit HTML”.
  8. Now you’ll see the XML of your blog.
  9. And Now search data:post.body/. If you cannot find it, copy the whole file and edit it externally using any text editor.
  10. 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 results 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 the 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 Blog Post.

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

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

            const adscont1 = document.getElementById("seoneurons-content1");
            const adscont2 = document.getElementById("seoneurons-content2");
            const target = document.getElementById("seoneurons-target");
            const linebreak = target.getElementsByTagName("br");

            if (linebreak.length > 0) {
                insertAfter(adscont1, linebreak[1]);
                insertAfter(adscont2, linebreak[3]);
            }
        </script>
    </div>
</b:if>
<b:if cond='data:view.isPage'>
    <data:post.body/>
</b:if>

Place the two AdSense ads in the space provided for ad code. We recommend you place a max of 2 ads if your article is 600 words long. If you place a higher number of ads, then invalid clicks may increase and lower the CPC you get. That is entirely a wrong practice.

  • target.getElementsByTagName("br"); Declares Ad location. Here to default tag for Blogger posts 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,

  • display an ad after 2 tags, then put 1 instead of 3, and so on.

You aim should be satisfy user so that he can stay on your website for a longer time and ultimately increase brand value and revenue. Try to deliver awesome content to increase your AdSense Ad revenue.

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.

JOIN THE CONVERSATION

Comments

Have a question or something to add? Comments are moderated and appear here only after approval.

59 published comments, including 23 replies. Threads shown oldest first.

  1. hyperReader #

    2nd code is not working for multiple ads

    1. ASHOK SIHMARReader #

      In reply to hyper

      Hello hyper, code modified. Try it now.

      1. Lovely AkterReader #

        In reply to ASHOK SIHMAR

        hello ashok sir i want say that if i have you know 10000 words or long blogs posts on my blogger and i want to add more than 2 ads on between paragraph of my post ,,then how will i will do that..and one more thing if some of my visitor of my blog will go to several of my other post will that visit will be count in rpm or 1000 visit to get the cpm money..if i have 100 visit per day on my blog..but if my visitor visit my other pages of post also..will i will get paid for that..plz kindly inform me that.. Love From Bangladesh

  2. Dealsyou.tkReader #

    how to place 3

  3. ASHOK SIHMARReader #

    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

    1. bhashan marathiReader #

      In reply to ASHOK SIHMAR

      not working for my site https://www.bhashanmarathi.com/

    2. bhashan marathiReader #

      In reply to ASHOK SIHMAR

      now worked thank u soo much

      1. Ashok Sihmar (Ashok Kumar)Author #

        In reply to bhashan marathi

        welcome

  4. ASHOK SIHMARReader #

    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

    1. GizmoxoReader #

      In reply to ASHOK SIHMAR

      thanks it really helped

  5. Mohamed ZayedReader #

    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

  6. Mohit PatilReader #

    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…

    1. Ashok Sihmar (Ashok Kumar)Author #

      In reply to Mohit Patil

      insertAfter(adscont,linebreak[2]) Replace 2 with your value. Thank you

  7. ronnieReader #

    Good day sir! how to place it right after the first paragraph? thank you so much!!!

    1. Ashok Sihmar (Ashok Kumar)Author #

      In reply to ronnie

      insertAfter(adscont,linebreak[2]) Change value 2 to 0, If we place 0 here, it will display ad after 1st para, if 1 it will display ads after 2nd

  8. Nitish SahniReader #

    I have done all but it is not showing in content ads in my website : https://mylearningmania.com Please help me anyone.

  9. Nitish SahniReader #

    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. In reply to Nitish Sahni

      Hey, you’re not copying the complete code. Please try again and do it carefully.

      1. Nitish SahniReader #

        In reply to Ashok Sihmar

        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.

  10. BUKUPROGRAMDOTCOMReader #

    tq ” it works on 3rd result of .”

  11. SPReader #

    Hello Ashok Sir, I am new to blogger could you please help me regarding code? My website is https://www.dailyvirtualassistants.com Thanks

  12. MiroslavReader #

    I am getting this error “The prefix “b” for element “b:if” is not bound.” Show us a way how to fix it. Nitish Sahni told you before about this.

    1. Ashok Sihmar (Ashok Kumar)Author #

      In reply to Miroslav

      You’re missing or taking some extra code

      1. MiroslavReader #

        In reply to Ashok Sihmar

        Ashok Kumar, maybe you have not been aware about the error but the the problem is this: The “copy BUTTON” you have on your website to copy the code does not copy the code correctly. But, things work like a charm after I copied the code “manually” rather than using the copy button.

        1. Ashok Sihmar (Ashok Kumar)Author #

          In reply to Miroslav

          Thanks Miroslav for your feedback. can you share the copied code with the copy button? This will help us a lot to understand the issue.

          1. MiroslavReader #

            In reply to Ashok Sihmar

            From the pastebin link below copy the raw code because that’s the original code from your website, the first is the one generated by pastebin. Something else: In the future, maybe I will do a video screenshot, for now test this and lets see if you can recreate the problem. https://pastebin.com/WLS6R8dF

  13. techtspotReader #

    thanks for the post that help me to add some ads in between the blog posts …

  14. SanjayReader #

    Thank you for your best help i’m new in blogging please check my blog and give me some basic tips indiatradefair.org

  15. DanielReader #

    Can these work with third party ads?

  16. Farhaan KhanReader #

    Note working for me site https://www.sakoonedil.com please help

  17. zafarReader #

    dear friend, I have a severe problem with my blogger HTML there is some coding under the footer area when anyone visits my blog How will I remove this coding from my blog I need your help please any solution. Please visit my blog then you will see it yourself. Thank you.

    1. Ashok Sihmar (Ashok Kumar)Author #

      In reply to zafar

      This problem is in the XML theme file. It seems you tried to remove default/unused CSS or JS https://seoneurons.com/en/blogger/remove-default-css-js/. Try to use the TezzBlog Blogger theme https://seoneurons.com/en/blogger-seo/seo-friendly-blogger-theme/tezzblog-blogger-xml-theme-download/.

  18. JohnReader #

    How to insert the AdSense code above the title?

    1. Ashok Sihmar (Ashok Kumar)Author #

      In reply to John

      Edit XML theme and search for <h1 tag. Paste Adsense code just above it and save the theme file.. done!

      1. JohnReader #

        In reply to Ashok Sihmar

        Search for what?

        1. Ashok Sihmar (Ashok Kumar)Author #

          In reply to John

          Edit XML file, and search for h1 heading tag. i.e. <h1 Paste the code just above <h1 tag.

          1. JohnReader #

            In reply to Ashok Sihmar

            There are many h1 tags and none of them seem to make sense to edit. If you could give a more detailed answer, it will be helpful.

          2. Ashok Sihmar (Ashok Kumar)Author #

            In reply to Ashok Sihmar

            Can you share the XML with our e-mail. Or you can inspect the heading items using ctrl/cmd+shift+I. And check the class or ID used by element. Find the same in the XML file..

  19. JohnReader #

    I am using the default blogger theme named “Notable.”

    1. Ashok Sihmar (Ashok Kumar)Author #

      In reply to John

      Default Blogger Themes are not SEO friendly as heading tag come under h3 tag.. and you may know the importance of h1 tag.. You can insert your code above h3 or we advise you to install tezzBlog Blogger theme..

  20. THE ANH NGUYEN HOANGReader #

    Thank you, for ” var adscont = document.getElementById(“seoneurons-content3″)” i put 3 ads

  21. khatib jameelReader #

    nicly explained bro

  22. MarathiReader #

    Its awesome, I try this on my blogger website, its really work. Thanks… https://marathio.in/

  23. मराठी भाषणReader #

    Wow thank you for Post it’s working

  24. Boobalu SpReader #

    Hi Sir, I Getting this error while trying to use your tutorial code, Can You Pls Help Me org.xml.sax.SAXParseException; lineNumber: 3124; columnNumber: 5; Element type “div” must be followed by either attribute specifications, “>” or “/>”.

    1. Ashok Sihmar (Ashok Kumar)Author #

      In reply to Boobalu Sp

      this is because the “div” element is not closed properly.

      1. Boobalu SpReader #

        In reply to Ashok Sihmar

        Hello sir, I used < and > to solve it but ads not displaying after a successful upload, what can do.. I used the same tutorial few months ago without modification but now only getting these errors 🙁

  25. Boobalu SpReader #

    Hello sir, I used < and > to solve it but ads not displaying after a successful upload, what can do.. I used the same tutorial few months ago without modification but now only getting these errors 🙁

  26. Vishal YadavReader #

    Thanks for this amazing Knowledge!!

  27. lyrics gaanaReader #

    its a very helpful artical can you check this website https//lyricsgana.com/

  28. lyrics gaanaReader #

    its a very helpful artical can you check this website https://www.lyricsgaana.com/

  29. lyrics gaanaReader #

    its a very helpful artical can you check my website https://www.lyricsgaana.com/

  30. Sport kheloReader #

    very helpful article check my site

  31. blessedReader #

    org.xml.sax.SAXParseException; lineNumber: 2415; columnNumber: 5; Element type “div” must be followed by either attribute specifications, “>” or “/>”. im getting this error please help

  32. GeorgeReader #

    How to place three ads in the post? How can i have 3 ads in long posts? https://www.bana.co.ke/2022/10/chelsea-vs-manchester-united-match-live.html

  33. Attipoe MartinReader #

    Pls, is there any other place to insert the code? I don’t have the place indicated in my html

  34. RafaelReader #

    The best article ever!! It gave what i needed

  35. Gordon ElderReader #

    My ads are not showing on mobile

  36. EscaperReader #

    Hi. Thank you for your valuable information. I want to ask you that how can we show ads for example after every 3 posts on homepage, label pages, search pages and archive pages?

JavaScript is required to submit a comment. Published comments above remain available to read.