Sunday, November 30, 2008

Ads in the middle

This method can be used both with old and new Blogger.
It is XHTML compliant and works with IE, FF, Opera, Safari.

Problem

In the famous Google AdSense heat map are reported the most profitable areas where to put advertising for your site or blog.
There is no mention of a placement in the middle of your posts. Why?
Because by default Blogger, the blogging platform offered by Google, doesn’t offer a way to break a post in the middle and put there an ad.
But, if you search very carefully on the Net, you’ll find that several webmasters tried to put ads in that position and report a significant increase in profits.

This site doesn’t confirm an increase in profits when an ad is in the middle of a post, but explains how to put AdSense in the middle of a Blogger post.


Solution

There is a simple way to solve this problem: move post body around the advertising code, just with a bunch of JavaScript and a couple of DIVs. In 2 easy steps:

1. In your Blogger template:

OLD BLOGGER

Find the tag <$BlogItemBody$> and replace it with 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>



NEW BLOGGER

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.

In every blog post:

2. Put a special comment


<!-- adsense -->

in the exact point you want to appear AdSense advertising.
Done!

Notes

There are a couple of different approaches to solve the stated problem, both not working:

1. Write all AdSense code block directly inside the post.

This is not working because Blogger will warn you it’s prohibited to insert JavaScript code inside a post.
Even bypassing the error (flagging Stop showing HTML errors for this post) what you’ll get is not what you wanted.

2. Write a JavaScript to move AdSense code block in the middle of our post.

While this method works, it’s prohibited by the Google ToS since you have to modify the AdSense code itself.


This method also works with other advertising systems, like Yahoo! Publisher Network (YPN), Microsoft adCenter, Chitika, AdBrite, or others.

ANOTHER ARTICLE MUST READ :

5 comments:

Anonymous said...

Mantap abies....

Anonymous said...

triknya keren...

jasminetea said...

wah baru tau ada trik" nya buat adsense boss...btw kreatif banget deh si boss ini...sukses boss

Anonymous said...

eh..bos..bos..trik tersebut ga ngelanggar Tos nya mbah google ta?

Anonymous said...

but why you say "While this method works, it’s prohibited by the Google ToS since you have to modify the AdSense code itself"

Post a Comment

Note: Only a member of this blog may post a comment.