How to Add In-Article Ads Automatically In Every Post Of Blogger Blog

How to Add In-Article Ads Automatically In Every Post Of Blogger Blog

You can quickly implement Adsense Ad code to show ads in the middle of every post. Your AdSense ads code will insert in every blog post automatically.

How to Add In-Article Ads Automatically In Every Post Of Blogger Blog?

This tutorial will discuss about How to automatically add AdSense ads or Advertisement into the middle of every Blogger blog post? So let's follow the steps provided below properly.


These are benefits of Adding Adsense Ads autometically in every Blog Post.

  1. It is very tough and time-consuming to pick 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. It's solution is to add the AdSense ads code or other advertisement once and relax. Your AdSense ads code will insert in every blog post automatically.
  2. We can quickly 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, read our article how to set up In-feed ads for Blogger (blogspot) blog.


How to apply 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 (blogspot) blog. Just copy the provided code, change ad unit values and place it as suggested in this article.


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

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



First of all generate your Native In-Article Ad

  1. Open the Google Adsense Account
  2. Go to the Ads
  3. How to Add In-Article Ads Automatically In Every Post Of Blogger Blog?
  4. Click on By ad unit and select Native in-article ads
  5. How to Add In-Article Ads Automatically In Every Post Of Blogger Blog?
  6. Generate Adsense Ad or any ads(Text and Image) code Click on Save and get code button
  7. How to Add In-Article Ads Automatically In Every Post Of Blogger Blog?
  8. Copy Google Adsense Ad Code and Click on I'm done button then, save it somewhere or stay on this page and open new tab or browser.
  9. How to Add In-Article Ads Automatically In Every Post Of Blogger Blog?

Edit your blogger template

  1. Now go to the draft.blogger.com
  2. Menu » Theme.
  3. Download the theme file for backup.
  4. Now click on Edit HTML.
  5. How to Add In-Article Ads Automatically In Every Post Of Blogger Blog?
  6. Now you’ll see XML of your blog. And Now search </main>.
  7. Copy bellow xml (html) Code and Paste it just above the </main>. If you couldn't find the code </main> on your blogger template paste just before </body> tag.

  8. 
    <b:section cond='data:view.isPost' id='in-article-ad-1' maxwidgets='1' name='In Article ADS 1' showaddelement='yes'>
        <b:widget id='HTML555' locked='true' title='' type='HTML' version='2' visible='true'>
            <b:widget-settings>
                <b:widget-setting name='content'><![CDATA[<!-- Place Your Adsense Ad code here -->]]></b:widget-setting>
            </b:widget-settings>
            <b:includable id='main'>
                <div class='html-content in-article-ads'>
                    <data:content/>
                </div>
            </b:includable>
        </b:widget>
    </b:section>
    

  9. Replace line <!-- Place Your Adsense Ad code here --> with the Adsense ad code, you have generated before.
  10. Now find </body> and Copy the following Javascript code, then, paste it just before </body>.

  11. 
    <script type='text/javascript'>
    //<![CDATA[
    // In Article Ad
    function insertAfter(Ads,targetAds) {var inarticlead = targetAds.parentNode;if (inarticlead.lastChild == targetAds) {inarticlead.appendChild(Ads);}else {inarticlead.insertBefore(Ads,targetAds.nextSibling);}};var targetAds = document.getElementById("post-body");var inarticleAd1 = document.getElementById("in-article-ad-1");var showinarticleAd1 = targetAds.getElementsByTagName("br");if (showinarticleAd1.length > 0) {insertAfter(inarticleAd1,showinarticleAd1[3]);};
    //]]></script>
    

  12. Now Save your template.

If this method is not working on your blog, find the code <data:post.body/> then replace <div id='post-body'><data:post.body/></div> instead of <data:post.body/>.

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/>.



If you want to add your adsense code automatically you don't need to generate your google adsense ad code manually just Replace line <!-- Place Your Adsense Ad code here --> with the following Adsense code. Replace line ca-pub-1234567890 with your google adsense publisher id.



<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890" crossorigin="anonymous"/>
<ins class='adsbygoogle' data-ad-format='auto' data-full-width-responsive='true' expr:data-ad-client='data:adClientId ?:data:blog.adsenseClientId' expr:data-ad-host='data:blog.adsenseHostId' expr:data-analytics-uacct='data:blog.analyticsAccount Number' expr:style='data:style ?: &quot; display:block;&quot;' style='display:block'> </ins><script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

If you have already installed Google Adsense Plugin script remove the adsense plugin script <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890" crossorigin="anonymous"/> from above Adsense Ad Code.


Changes to be made:

  1. Replace <!-- Place Your Adsense Ad code here --> with your own Google ads code.
  2. This code you replaced will appear in the middle of Blogger Blog as an Adsense ad.
  3. The Adsense Ad will place after the 3rd <br /> of the Blogger post.

Place Multiple AdSense ads Automatically in Every Post of Blogger

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


xml (html) Code for Multiple AdSense ads Automatically in Every Post of Blogger


<b:section cond='data:view.isPost' id='in-article-ad-1' maxwidgets='1' name='In Article ADS 1' showaddelement='yes'>
    <b:widget id='HTML555' locked='true' title='' type='HTML' version='2' visible='true'>
        <b:widget-settings>
            <b:widget-setting name='content'><![CDATA[<!-- Place Your Adsense Ad code here -->]]></b:widget-setting>
        </b:widget-settings>
        <b:includable id='main'>
            <div class='html-content in-article-ads'>
                <data:content/>
            </div>
        </b:includable>
    </b:widget>
</b:section>

<b:section cond='data:view.isPost' id='in-article-ad-2' maxwidgets='1' name='In Article ADS 2' showaddelement='yes'>
    <b:widget id='HTML666' locked='true' title='' type='HTML' version='2' visible='true'>
        <b:widget-settings>
            <b:widget-setting name='content'><![CDATA[<!-- Place Your Adsense Ad code here -->]]></b:widget-setting>
        </b:widget-settings>
        <b:includable id='main'>
            <div class='html-content in-article-ads'>
                <data:content/>
            </div>
        </b:includable>
    </b:widget>
</b:section>


Javascript Code for Multiple AdSense ads Automatically in Every Post of Blogger


<script type='text/javascript'>
//<![CDATA[
// In Article Ads
function insertAfter(Ads,targetAds) {var inarticlead = targetAds.parentNode;if (inarticlead.lastChild == targetAds) {inarticlead.appendChild(Ads);}else {inarticlead.insertBefore(Ads,targetAds.nextSibling);}};var targetAds = document.getElementById("post-body");var inarticleAd1 = document.getElementById("in-article-ad-1");var showinarticleAd1 = targetAds.getElementsByTagName("br");if (showinarticleAd1.length > 0) {insertAfter(inarticleAd1,showinarticleAd1[3]);};var inarticleAd2 = document.getElementById("in-article-ad-2");var showinarticleAd2 = targetAds.getElementsByTagName("br");if (showinarticleAd2.length > 0) {insertAfter(inarticleAd2,showinarticleAd2[6]);};
//]]></script>


Place the two different AdSense ads in the <!-- Place Your Adsense Ad code here -->. We recommend you to 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 completely a wrong practice.

  1. targetAds.getElementsByTagName("br"); Declares the ads’s location. Here to default tag for Blogger post is br for the break <br />.
  2. 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.
  3. insertAfter(inarticleAd1,showinarticleAd1[n]); or insertAfter(inarticleAd2,showinarticleAd2[n]); Declared how many tags the ads should be visible. Where numerial=number of tags-1, i.e., If you want to show ad for 4 tags, n will be 4-1=3.
  4. So if you want to display after 1 line break, then place 0 instead of 4, display an ad after 2 tags, then put 1 instead of 3, and so on.

We aim to increase AdSense revenue of our website or blog. For this, focus on writing SEO Friendly content that leads results in high CPC.

Mero Blogging Tips

Mero Blogging Tips Share Blogger Tutorials, HTML, JavaScript, CSS, Widget, SEO, jQuery, Web Tool and General Helpful Stuff for Newbie Bloggers and Readers.

2 Comments

First of all, thank you for taking the time to read my blog. It's much appreciated! If you would like to leave a comment, please do, I'd love to hear what you think!. Suggestions and/or questions are always welcome, either post them in the comment form.

However, comments are always reviewed and it may take some time to appear. Also, Comments without NAME will not be published. Always keep in mind "URL without nofollow tag" will consider as a spam.

  1. Good work sir
    I need help to add automatic mluti ads to articals but not adsense its adstera

    ReplyDelete
    Replies
    1. Replace your Adsterra ads code instead of Google Adsense Ads code

      Delete
Previous Post Next Post

Published Blogger Posts
40+

Years of Envolving
3+

Contact Form