![]() |
| Place Adsense Ads In Middle of The Post in Blogger |
Place Adsense Ads Automatically In Middle of All The Posts In Blogger:
Step 1: the First Thing we need to do is to Parse the AdSense code and convert it to plain text.Then go to "Template", click on the "Edit HTML" button and click anywhere inside the code area to search using CTRL + F keys for this:
<data:post.body/>Note: You will get multiple codes similar to the above code. You have to select the second code which is similar to the above code in order to make the script work properly.
Step 2. Replace <data:post.body/> with this code:
<div expr:id='"adsmiddle1" + data:post.id'></div>Step 3. Add the converted Adsense code on where you see the <!-- Add here the code of your ad --> annotation, then save the changes by clicking on the "Save template" button.
<b:if cond='data:blog.pageType == "item"'>
<b:if cond='data:blog.pageType != "static_page"'>
<div style="clear:both; margin:10px 0">
<!-- Add here the code of your ad -->
</div>
</b:if>
</b:if>
<div expr:id='"adsmiddle2" + data:post.id'>
<data:post.body/>
</div>
<script type="text/javascript">
var obj0=document.getElementById("adsmiddle1<data:post.id/>");
var obj1=document.getElementById("adsmiddle2<data:post.id/>");
var s=obj1.innerHTML;
var r=s.search(/\x3C!-- adsense --\x3E/igm);
if(r>0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+16);}
</script>
Note: For centering the ads, add the <center></center> tags before and after the AdSense code, like this:
<div style="clear:both; margin:10px 0">
<center>
<!-- Add here the code of your ad -->
</center>
</div>
Step 4. When you create a New Post, add this annotation inside the "HTML" section to where you want the Google AdSense ads to appear:
<!-- adsense -->
For example:
On-Page Seo. On-page SEO is the practice of optimizing individual web pages in order to rank higher and earn more relevant traffic in search engines.<br /><br /> <!-- AdSense --> On-page refers to both the content and HTML source code of a page that can be optimized, as opposed to off-page SEO which refers to links and other external signals.
AdSense annotation in the middle of the post content
Please note that if you don't add this annotation to specify where to display the ad, then it will appear below the title by default.
Method 2
Place Adsense Ads Automatically In Middle of All The Posts In Blogger:
Follow The below process to place Adsense ads in Middle of all the posts automatically in blogger.
Step 1:
Login to Your Blogger Account
Go to Template >Edit HTML
Step 2:
Search For Below Code in your template.
<data:post.body/>
You will get multiple codes similar to above code. You have to select the second code which is similar to above code in order to make the script work properly.
Step 3:
Replace The above Code With The Below Code.
<div id='jobmiddlenew'>
<data:post.body/> </div>
<b:if cond='data:blog.pageType == "item"'>
<style> #addcodemiddle{display: none;} </style>
<div id='addcodemiddle'> Place Your Ad Code Here </div>
<script type='text/javascript'> var str1=document.getElementById("jobmiddlenew").innerHTML; var str2=str1.length; var str3=str2/2; var substr = str1.substring(str3, str2); var n = substr.search("<br>"); if(n<0) { n = substr.indexOf('.'); if(n<0) { n=0; } var firsthalf = str1.substring(0, str3+n+1); var secondhalf = str1.substring(str3+n+1, str2); } else { var firsthalf = str1.substring(0, str3+n+4); var secondhalf = str1.substring(str3+n+4, str2); } var addcode="<center>"+document.getElementById("addcodemiddle").innerHTML+"</center><br/>"; var newbody=firsthalf+addcode+secondhalf; var strnew=document.getElementsByClassName("post-body entry-content"); strnew[0].innerHTML=newbody; document.getElementById("addcodemiddle").innerHTML=""; </script>
</b:if>Step 4
Replace The Place Your Ad Code Text With Your Adsense Ad Code in the above code and save your template.
So this is how we can add AdSense ads in the middle or anywhere inside our Blogger posts. Don't worry about violating Google's Terms of Service because applying this method will not modify the ad' structure.




0 Reviews:
Post Your Review