Skip to main content

How To Put AdSense Ad Anywhere Inside Blog Post

We all know that Google AdSense is one most preferred affiliate money making program run by Google. It is a cookie based contextual advertising program that shows targeted ads, relevant to the content and reader of a website. I had already showed you, how to add this ad below blog post title and below blog post. In this post, I will show you how to add this ad inside the blog post together with the ad below blog post title and below blog post. To add the ad code inside your blog post you need to perform the below steps carefully. Read also : How to protect your computer from WannaCry ransomware virus.

Steps to Create Google ad code

To create the ad code follow the below the five steps.

Step 1. At first login to your Google AdSense account.

Step 2. After login, click My ads and then click New ad unit

Step 3. Now you have two options to choose. One is Text & display ads and another is Matched content. You need to click Text & display ads. Read also : How to create and setup matched content ad unit.

Step 4. Type ad unit name and choose ad size. If you want large rectangle ads with 336 x 280 dimension then choose it otherwise I recommend you to choose Responsive ads to get better page impression.

Step 5. Now click Save button and then Copy the code.

Steps to add the code Inside Template

Step 1. Now in the below code, replace Add the code here with your own code and then Copy the whole code.

<div expr:id='&quot;adsmiddle1&quot; + data:post.id'/>
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<b:if cond='data:blog.pageType != &quot;static_page&quot;'>
<div style='clear:both; margin:10px 0'>
<center>
Add the code here
</center>
</div>
</b:if>
</b:if>
<div expr:id='&quot;adsmiddle2&quot; + data:post.id'>
<data:post.body/>
</div>
<script type='text/javascript'>
var obj0=document.getElementById(&quot;adsmiddle1<data:post.id/>&quot;);
var obj1=document.getElementById(&quot;adsmiddle2<data:post.id/>&quot;);
var s=obj1.innerHTML;
var r=s.search(/\x3C!-- adsense --\x3E/igm);
if(r&gt;0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+16);}
</script>

Step 2. Now switch to your blogger dashboard and click Theme / Template and then click Edit HTML.

Step 3. Now click any where inside the code and then press Ctrl + F on the keyboard to get search box.

Step 4. Type <data:post.body/> in the search box and hit enter on the keyboard. You will get this option twice or more time depending upon the template / theme but you have to stop at the second option.

Step 5. Now you need to replace  <data:post.body/>  with the above code to appear the ads anywhere inside the each blogger post. And to avoid any error or parse the template / theme, replace async with async='' of the ad code.

Step 6. Finally, click Save theme.

Steps to add the code Inside Blog Post

Now you just need to create a New Post and then click HTML and add <!-- adsense --> code where you want to display the ad  inside the blog post. After that Publish the post. You can also add the code in an existing blog post.


That's it! Cheers. Feel free to comment and share this post on social networks as well as subscribe to this blog.


Comments