Wednesday, January 4, 2012

how to put AdSense ads inside a post

1 comment
You have searched many times to find the article on how to put adsense ads inside a 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”

Convert your adsense code for Blogger

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/>


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 -->
</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>




Now replace the “Your AdSense code” with your parsed AdSense code copied in step 4.

10. Now save your template

11. Then go to DASHBOARD >> NEW POST >> EDIT HTML

12. Copy and paste the following code, just before publishing your post, at the place where 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 view it.

Now you know how to add AdSense ads anywhere inside your post. Now this is the time to leave a comment and share this with your friends. Happy blogging..!!

1 comment:

  1. @abhiskek For how much time this hosting is free ?

    ReplyDelete