The method described below can be used both with old and new Blogger And, since It is XHTML compliant, it will work with IE, Firefox, Opera, and Safari.
Many of you will be familiar with the famous Google AdSense heat map which shows the areas of your website or blog where you should place advertising in order to maximize your profits. Oddly enough, there is no mention of a placement in the middle of your posts.
Why?
Because by default Blogger, the blogging platform offered by Google, does not offer a way to break a post in the middle (or someplace else) so you can place an ad there.
But, if you search the Net thorougly, you will find that quite a lot of webmasters have managed to put ads in that position and report a significant increase in profits.
While I cannot as yet confirm a considerable increase in profits when ads are placed in the middle of posts, I´ll nevertheless explain in this post how to place Adsense in the middle of Blogger posts.
How to place Adsense in the middle of Blogger posts:
The solution to this problem is quite simple: you only need to move the post body around the advertising code, just with a bunch of JavaScript and a couple of DIVs (divisions). All it takes are 2 easy steps:
1. In your Blogger template: Dashboard –> Layout –> Edit HTML –> Expand Widget Templates
Find the tag <data:post.body/> and replace it 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>
IMPORTANT NOTICE: Do not forget to replace <!-- Your AdSense code --> with the ad code provided by Google Adsense. Also, the ad code needs to be converted before you can insert it.
2. In every blog post:
Place the special comment
<!—adsense -->
in the exact spot you want the Adsense ads to appear.
That´s all!
Frequently Asked Questions:
1. Does this method violate Google Adsense Terms and Conditions?
Definitely not. Answering a direct support request Google stated this method doesn't violate any of their program policies.
2. What if I forget to put in a post the <!-- adsense --> comment?
Nothing. The advertising block will appear in the traditional position as defined in your template before you implemented this modification (in most cases just below the title).
3. What happens on Blogger home page and archive pages when several posts with the <!-- adsense --> comment appear together?
Exactly the same thing that happened before this modification: The Google Adsense service automatically inserts up to 3 AdSense blocks per page in your posts. That means only the first 3 posts (in a top-down order) on your home page or archive pages will show ads.
4. Is it possible for me to automate the insertion of AdSense in the middle of my posts without having to manually place the <!-- adsense --> comment?
Yes, it is. But you will have to replace the JavaScript code listed above with the following one:
<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 t=s.substr(0,s.length/2);
var r=t.lastIndexOf(" ");
if(r>0) {obj0.innerHTML=s.substr(0,r);obj1.innerHTML=s.substr(r+1);}
</script>
Notes:
You may have heard of a couple of different approaches to solve the stated problem that sound simple but, unfortunately, are not working:
1. Copying the Adsense code directly into the post.
This does not work because Blogger will warn you that it is prohibited to insert JavaScript code inside a post (or show some kind of error warning). Bypassing the error warning by flagging ‘Stop showing HTML errors for this post’ will not get you the desired result.
2. Writing a JavaScript to move the AdSense code block in the middle of your post.
This method is prohibited by the Google Adsense Terms and Conditions because you have to modify the AdSense code itself. If you do it anyway, no ads will be shown (you will get an error information stating the website or service is not available).
The method described above also works with other advertising systems, for instance Yahoo! Publisher Network (YPN), Microsoft adCenter, AdBrite, Chitika, and a host of others.