Tuesday, April 12, 2011

HOW TO PUT ADSENSE IN THE MIDDLE OF BLOGGER POSTS



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.

  2. In every blog post:

    Put a special comment
    <!-- adsense -->
    in the exact point you want to appear AdSense advertising.
    Done!
Look at the old Blogger example
Look at the new Blogger example



Questions
  1. Does this method violate Google ToS?

    No. 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 you defined in your template before implementing this modification.

    Look at the example

  3. What happens in Blogger home page and archive pages where there several posts with <!-- adsense --> comment appears together?

    Exactly the same thing happening before this modification: 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.

    Look at the example

  4. Can I automate the injection of AdSense in the middle of my posts without manually inserting the <!-- adsense --> comment?

    Yes, but you’ll need to change the JavaScript code listed above with the following one:


    OLD BLOGGER

    <script type="text/javascript">
    var obj0=document.getElementById("prv<$BlogItemNumber$>");
    var obj1=document.getElementById("fst<$BlogItemNumber$>");
    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>


    NEW BLOGGER

    <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>


    Look at the old Blogger example
    Look at the new Blogger example

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.


by:http://adsinthemiddle.blogspot.com/

No comments:

Post a Comment