Put AdSense ads anywhere inside a post

One of my earlier postsdescribed how to add your AdSense ads inside a blog post. But thatcode will not help you to add AdSense ads at the middle of your post. It onlyallows you to add the ads at the left or right or the center of the post.

Today one of my friend ask mecan she add the AdSense in the middle of the post by using the code I posted inHow to add AdSense inside a post. I told her no, she can’tand promised her to add the trick later. I thought not to delay it any more. Sothis post will show you how to put AdSense anywhere inside your post.
Letme explain the process;

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

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

3.    Thenyou have to convert your code

Otherwise your ad will notbe compatible with Blogger. But you don’t need to change it manually. Use thefollowing link to change your ad for blogger. Paste your code inside the blankand click on “PARSE”

4.   Copy the converted code.

5.    Nowgo to your blog >> Dashboard >> Design >> Edit HTML

6.    Puta tick on “Expand Widget Templates”

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


8.    Nowreplace 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 –>
<div expr:id=’”aim2″ + data:post.id’>
<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);}
9.    Nowreplace the “Your AdSense code” with your parsed AdSense code copied in step 4.

10. Nowsave your template


12. Copyand paste the following code, just before publishing your post, at the placewhere you want to display the AdSense ads. After you did this you will not go back to compose mode. You should publish your post in HTML mode. So do this as your last step.

<!– adsense –>

13.Publish your post and viewit.

Now you know how to add AdSenseads anywhere inside your post. Now this is the time to leave a comment andshare this with your friends. Happy blogging..!!

0 التعليقات:

Post a Comment

Related Posts Plugin for WordPress, Blogger...