How to Add AdSense Ads Middle/Below Titles/Anywhere Inside Blogger

Adding AdSense Ads in Blogger

How to Add AdSense Ads Middle/Below Titles/Anywhere Inside Blogger

In a previous blog post, we discussed adding AdSense ads to specific locations in Blogger. But what if you want to display ads in the middle of your posts or anywhere else within the content, like below titles or at the end of the post footer? Follow these simple steps to achieve that:

Step 1: Backup Your Template

Before making any customizations, it's essential to back up your template. Go to the Blogger dashboard, navigate to "Template," and click on "Backup/Restore."

Step 2: Modify the Template HTML

Click on the "Edit HTML" button in the Template section. Look for the code <data:post.body/> using the CTRL+F keys. Locate the second occurrence of this code (or the third if necessary).

Step 3: Replace the Code

Replace <data:post.body/> with the following code:

<div expr:id='"adsmiddle1" + data:post.id'></div>
<b:if cond='data:blog.pageType == "item"'>
  <b:if cond='data:blog.pageType != "static_page"'>
    <div style="clear:both; margin:10px 0">
      <!-- Add here your AdSense Code -->
    </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>
  

Step 4: Add AdSense Code in the Post

For centering your AdSense ads, add the <center> tags before and after your AdSense code. Place your converted AdSense code inside the annotation <!-- Add here your AdSense Code -->. Save your template after making the changes.

Adding AdSense Ads Inside the Post Content

To display AdSense ads within your post content, add the following HTML tag where you want the ads to appear:

    <!-- adsense -->
  

Note:

By default, the ads will be visible below the post title unless you apply the <!-- adsense --> HTML tag inside your post during creation.

Next Post Previous Post