How to add Adsense at anywhere inside the Post of Blogger

Today one of my friend ask me, can she add the AdSense in the middle of the post by using the code I posted in How to add AdSense inside a post. I told her no, she can’t and I promised her to add the trick later. I thought not to delay it any more. So this post will show you how to put AdSense anywhere inside your post.




Let me explain the process;


1.   First you should go to your adsense account and grab the code for your adsense ads.

2.    For this you should Sign in to adsense >> My ads >> New ad unit>> Change ad appearance >> Save and Get code

3.    Then you have to convert your code

Otherwise your ad will not be compatible with Blogger. But you don’t need to change it manually. Use the following link to change your ad for blogger. Paste your code inside the blank and click on “PARSE”


4.   Copy the converted code.

5.    Now go to your blog >> Dashboard >> Design >> Edit HTML

6.    Put a tick on “Expand Widget Templates”

7.    Then press “Control + F” on your keyboard and search following code

<data:post.body/> 

Note :- You May find several times this code, so You have to stop on Second one and countinue below Procedure


8.   Now replace the above code with the following code

<div expr:id='"aim1" + data:post.id'></div>

<div style="clear:both; margin:10px 0">

    <!-- Your AdSense code here -->
</div>

<div expr:id='"aim2" + data:post.id'>

    <data:post.body/>
</div>

<script type="text/javascript">
var obj0=document.getElementById("aim1<data:post.id/>");
var obj1=document.getElementById("aim2<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:- that you must replace <!-- Your AdSense code --> with block code provided by Google.




In every blog post:

Put a special code while posting (Add code through HTML mode)
<!-- adsense -->
in the exact point you want to appear AdSense advertising. You can Put this code Several times in same post as per your Requirements.


Done!