Showing posts with label Adsense. Show all posts
Showing posts with label Adsense. Show all posts

Thursday, September 17, 2009

How to put AdSense in the middle of Blogger posts

Some webmasters try to put Adsense in a posting and has proven effective way of improving profits significantly.

There is a simple way how to put AdSense in the middle of a Blogger post, only with JavaScript and a group of some DIVs. Within 2 easy steps:

The first step:

Please log in Blogger, then the layout select edit HTML. In your Blogger template, find the tag <data:post.body/> (you must check Expand Widget Templates in Blogger console) and replace it with 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.

Step two:

In every blog post: Put a special comment

<! - Adsense ->

in the exact point you want to appear AdSense advertising.

Google automatically inject in your posts up to 3 AdSense blocks. So just the first 3 posts (in a top-down order) in your home page or archive pages will have ads.