• Archives

  • November 2009
    M T W T F S S
     1
    2345678
    9101112131415
    16171819202122
    23242526272829
    30  
  • Categories

  • Recent Posts

How to insert Ads Code ( Adsense, Adbrite, ..etc ) inside Blogger Post

This post explains you how to show your ads right after blog title.If you are using Expandable Summary hack ( Read More! ) to show part of the post on the front page, it’s better to show the ads within the individual posts. For that you need to place ads code between conditional control statments. I have explain this in the following section. Following image shows how ad looks on individual posts but not on home page.



If you try to insert Google AdSense or any other JavaScript-based ad code to the template, Blogger may deny and return you an error message like this:

Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly. XML error message: The processing instruction target matching “[xX][mM][lL]” is not allowed.

In case there’s no error returned, the ads still won’t show anything.

The problem is that ad code or client side javascipt code is not a valid XML. It will be confused when trying to interpret your template syntax.

The solution is replacing special characters or symbols in the script to HTML code. These HTML codes will be rendered correctly when the page is generated to the viewer. Following list shows special characters that need to be converted to HTML code.

Lets look follwing steps….

1. Take Your ads code ( I have used an example ad code, use yours )


<!–
google_ad_slot = “3780780821”;
google_ad_width = 468;
google_ad_height = 60;
//–>

<script type="text/javascript"
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”&gt;

2. Replace as follows

Character Replaced with
< <
> >
"

3. Converted code looks like as follows


<script type="text/javascript"><!–

google_ad_slot = "3780780821";
google_ad_width = 468;
google_ad_height = 60;
//–>
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
</script>

4. Now go to Blogger Dashboard >> Layout >> Edit HTML

5. Expand widget Template ( First take backup of your template )

6. Now search for this code

7. If you want to put the ads at the top of post or below post title, place it above this code, and if you want to put the ads at the bottom of the post ( footer ), just put it under this code.

8. If you have applied the “Read more” hack to show part of the post on the front page, it’s better to show the ads within individual posts.So place ad code between as shown below

put your ad code here….

The conditional code in pink will check whether the page is individual or front page.If the page is individual post page, than ads will shows below the post title otherwise ads will not show up ( for front page ).

Leave a comment