How to put adsense anywhere in your blog post!

Friday, December 14, 2007 | Labels: | |

[Source] This is a tutorial to let you put adsense anywhere inside your blogger post. It works for both the old blogger and the beta blogger. If you look through my blog, you'll see that I got it pretty much in every post. You can experiment with this and put multiple ads in, but in here i will only tell you how to put a single block of ads anywhere inside your post.

It should look like this when it's done.Ok, first, start off by logging into your adsense account and create a new ad. I suggest something small, like a banner or a small square. Get the code, copy it, and paste it into the adsense parser. Press parse, now copy that parsed code.

For new Blogger
Go to your template section, press edit html, check expand widget templates, hit ctrl-f and find "data:post.body", now replace that tag 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>
Replace "your adsense code" with your parsed adsense code.

For old Blogger
Find the $BlogItemBody$ tag, and replace it with the following code.

<div id="prv<$BlogItemNumber$>"></div>

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

<!-- Your AdSense code -->

</div>

<div id="fst<$BlogItemNumber$>">

<$BlogItemBody$>

</div>

<script type="text/javascript">
var obj0=document.getElementById("prv<$BlogItemNumber$>");
var obj1=document.getElementById("fst<$BlogItemNumber$>");
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
Now in every blog post, simply type
<!-- adsense -->
wherever you want adsense to appear.
Ps. Remember that google only allows 3 ad blocks per page. If you try to display more, it just won't show.

Have fun and good luck monetizing!

1 comments:

  1. Admin says:

    This is good, but problem is that this shows adsense on each post on my homepage, so I loose adsense in sidebar, ana posts on homepage ( after first 3 ) have an ugly empty space.
    So, is there a tip, how to exclude this from homepage ?

 
Free URL Redirection @ .co.nr