Sunday, February 11, 2007

Putting Adsense Code in New Blogger

Inserting Adsense code in New Blogger (previously called Blogger Beta) is a little bit confusing, because the facilities is different with Old Blogger. But after a hard searching in the internet and a time consuming trial and error, finally I succeeded putting the code as I wish.
 
I need to have my adsense in the post content automatically, as what I did in the classic Blogger template, where I can easily placing Google Adsense code anywhere by directly editing the HTML code of Blogger template. However, it is not easy for me to deal with HTML code of New Blogger template.
 
Just to share, here are the things you have to do if you want to display your adsense at the end of the post content:
  1. Prepare your adsense code in notepad
  2. Just do a little change to your adsense code. (Don't worry, this don't violate any of the Google TOS).
     
    The original code:
     
    <script type="text/javascript"><!--
    my ads code
    //--></script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
     
    Replace the <!-- and //--> with &lt;!-- and //--&gt; so the code will be seen like this:
     
    <script type="text/javascript">&lt;!--
    your ads code
    //--&gt;</script>
    <script type="text/javascript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
    </script>
      
     
  3. Login to your new blogger and go to Layout > Edit HTML > . Check the "Expand widget templates" and then search for the following term: 'post-footer-line post-footer-line-1'
  4. Now copy the 'modified' Adsense code and paste it just under the 'post-footer-line post-footer-line-1'. You may add <br/> after your adsense code to avoid of being too close to the next line in your post content.
  5. Click preview to ensure that there's nothing wrong with what you have done.
  6. Satisfied with your work? Then save your work.
Note: If you want to place your adsense at the beginning of your post, just place your code under 'post-header-line-1' (see step 3 and 4 above).

No comments: