Place Ads in Middle of Blogger Posts
When you make a Blogger template, you can place ads in the sidebar and on top. However, the positions of the ads are static. The main point is that you cannot place an advert inside a post. Correct?
Incorrect! Using a bit of Javascript techno-wizardry you can place AdSense ads in the middle of your Blogger posts easily. I don't promise, but it should increase your CTR. Let me show you how:
- Log in to Blogger and go to Template
- Find the <$BlogItemBody$> tag in your template
- Replace it with:
<p>
<ItemPage>
<div id="adsensical<$BlogItemNumber$>start"></div>
<div style="margin:5px 0 -5px 10px">
<!--PLACE YOUR AD CODE HERE-->
</div>
<div id="adsensical<$BlogItemNumber$>end">
</ItemPage>
<div id="adsensical<$BlogItemNumber$>body"><$BlogItemBody$></div>
<ItemPage>
</div>
<script language="JavaScript">
//AdSensical Place Ads in Middle of Blogger Posts
//By hackman_3vilGuy http://adsensical-adsense.blogspot.com
//hackman {AT}caller {DOT}me {DOT}uk
var topbit=document.getElementById("adsensical<$BlogItemNumber$>start");
var bottombit=document.getElementById("adsensical<$BlogItemNumber$>end");
var s=document.getElementById("adsensical<$BlogItemNumber$>body").innerHTML;
var regexIndex=s.search(/<!--adsense-->/igm);
if(regexIndex>0) {topbit.innerHTML=s.substr(0,regexIndex);bottombit.innerHTML=s.substr(regexIndex+14);}
</script>
</ItemPage>
</p>
Copy this code
- Replace <!--PLACE YOUR AD CODE HERE--> with your real Adsense code you want to put in
- Now in every post place <!--adsense--> somewhere in the HTML (click Edit HTML) of the post where you want the ad to appear!
Labels: adsense, blog, javascript, optimization