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.
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>
- Copy the above code and paste it into Notepad or any text editor application.
- Open the Google Adsense Account
- Generate Adsense Ads or any ads(Text and Image) code.
- Replace line <!–Place Your Prased Adsense Ad code here–> with the Adsense code.
- Now Open blogger.com and select “Theme”.
- Download the theme file for backup.
- Now click on “Edit HTML”.
- Now you’ll see the XML of your blog.
- And Now search data:post.body/. If you cannot find it, copy the whole file and edit it externally using any text editor.
- 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 isbrfor 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.
JavaScript is required to submit a comment. Published comments above remain available to read.
59 published comments, including 23 replies. Threads shown oldest first.
In reply to hyper
In reply to ASHOK SIHMAR
In reply to ASHOK SIHMAR
In reply to ASHOK SIHMAR
In reply to bhashan marathi
In reply to ASHOK SIHMAR
In reply to Mohit Patil
In reply to ronnie
In reply to Nitish Sahni
In reply to Ashok Sihmar
In reply to Miroslav
In reply to Ashok Sihmar
In reply to Miroslav
In reply to Ashok Sihmar
In reply to zafar
In reply to John
In reply to Ashok Sihmar
In reply to John
In reply to Ashok Sihmar
In reply to Ashok Sihmar
In reply to John
In reply to Boobalu Sp
In reply to Ashok Sihmar