Trick to Add AdSense, AdBrite and Other JavaScript Ad Code Directly to Blogger HTML Template

Advanced users of Blogger.com service may have tried to insert and put Google AdSense ad code which is actually a Java script directly into the blog pages by manually editing the XML-based template HTML coding interface. Actually, it’s possible add any ad code by using HTML/JavaScript page element within the Blogger new XML template system, but the place where you can place the new block is rather limited, i.e. above or below the post body, header, footer, within sidebar or between blog posts. In case you want to put the ads inside the post, or align the ads to float and wrap around the text, or just within the single individual article content view, you will have to edit directly the HTML coding of Blogger template.

If you try to insert any Google AdSense, AdBrite, AdEngage and any other JavaScript based ad code, or client-side components such as counter, tracker, form, snippet, effect, date and time, etc which is JavaScript based, the following error message may be returned when saving ore previewing:

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.

or

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 reference to entity “zs” must end with the ‘;’ delimiter.

and many other different XML error message.

The problem is caused by incorrect dynamic interpretation of Blogger XML template when it generates the HTML webpage for the blog page that is requested, probably due to the fact that the AdSense ad code or other code is not a valid XML, coupled with the fact that some ASCII characters have special meaning and reserved functions, confusing Blogger blogging engin.

The resolution to the JavaScript based coding does not work in Blogger HTML template error can be solved by replacing special characters or symbols in the script to HTML code. Check out the list below for which ASCII characters that need to be replaced with their corresponding HTML code. Using HTML code will ensure that Blogger render the character correctly when serving the page to the viewer.

< - &lt;
> - &gt;

Above two is enough to make Google AdSense works in Blogger template. For other scripts, such as AdBrite ad code, you will need to replace more characters such as those listed below.

& = &amp;
” = &quot;

For example, a Google AdSense code should become looks similar to code below:

&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "pub-XXXXXXXXXXXXXXX";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text_image";
google_ad_channel = "";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_text = "000000";
google_color_url = "000000";
//--&gt;&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;

While an AdBrite ad code will became the similar code to the below:

&lt;script type="text/javascript"&gt;
var AdBrite_Title_Color = '0000FF';
var AdBrite_Text_Color = '000000';
var AdBrite_Background_Color = 'FFFFFF';
var AdBrite_Border_Color = 'FFFFFF';
&lt;/script&gt;
&lt;script src="http://ads.adbrite.com/mb/text_group.php?sid=303771&amp;zs=3330305f323530" type="text/javascript"&gt;&lt;/script&gt;
<div><a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=303771&amp;afsid=1" style="font-weight:bold;font-family:Arial;font-size:13px;">Your Ad Here</a></div>

Simply use the text editor to parse the code and then replace the characters. Don’t worry about violating AdSense TOS or other terms and conditions, as once the blog’s web pages are rendered and presented to the viewers and visitors, the code will be exactly same as the original code before any replacement!

Share and contribute or get technical support and help at My Digital Life Forums.



33 Responses to “Trick to Add AdSense, AdBrite and Other JavaScript Ad Code Directly to Blogger HTML Template”

  1. How to Wrap AdSense Ads Around and Inline Beside Blogger Post Content » My Digital Life
    September 23rd, 2007 18:28
    1

    [...] Parsed Google AdSense Ad Code (guide to parse the HTML code of AdSense JavaScript with escape character) [...]

  2. BW
    October 2nd, 2007 09:58
    2

    Hi,

    When I tried this technique on my blogger site for Chitika ads (javascript) it just displayed the add block as text on the site - what am I missing

  3. admin
    October 2nd, 2007 10:51
    3

    Please make sure you have replace all < and > with &lt; and &gt;, including the one in ch_selected < ch_queries.length line.

  4. BW
    October 3rd, 2007 05:58
    4

    Thanks for the reply

    I tried changing the ch_selected

  5. BW
    October 3rd, 2007 06:57
    5

    try again

    I changed all the

  6. Nawin
    October 7th, 2007 15:07
    6

    Can somebody please show me how the entire chitika code will look like?

    Thanks

  7. NS
    October 7th, 2007 18:57
    7

    Ok made all the replacement as instructed but I am getting the same results as BW block text appears in my codes.

    <script type=”text/javascript”><!–
    ch_client = “xxxxxxxxx”;
    ch_width = 468;
    ch_height = 180;
    ch_color_border = “000000″;
    ch_color_bg = “000000″;
    ch_color_title = “FFFFFF”;
    ch_color_text = “FFFFFF”;
    ch_non_contextual = 1;
    ch_default_category = “81″;
    var ch_queries = new Array( “xxx”, “xxx”, “xxx” );
    var ch_selected=Math.floor((Math.random()*ch_queries.length));
    if ( ch_selected < ch_queries.length ) {
    ch_query = ch_queries[ch_selected];
    }
    //–></script>
    <script src=”http://scripts.chitika.net/eminimalls/mm.js” type=”text/javascript”>
    </script>

  8. NS
    October 7th, 2007 18:59
    8

    I made the changes as instructed above and still got text in blog. See codes below. Kindly advise.

    <script type=”text/javascript”><!–
    ch_client = “xxxxxxxxx”;
    ch_width = 468;
    ch_height = 180;
    ch_color_border = “000000″;
    ch_color_bg = “000000″;
    ch_color_title = “FFFFFF”;
    ch_color_text = “FFFFFF”;
    ch_non_contextual = 1;
    ch_default_category = “81″;
    var ch_queries = new Array( “xxx”, “xxx”, “xxx” );
    var ch_selected=Math.floor((Math.random()*ch_queries.length));
    if ( ch_selected < ch_queries.length ) {
    ch_query = ch_queries[ch_selected];
    }
    //–></script>
    <script src=”http://scripts.chitika.net/eminimalls/mm.js” type=”text/javascript”>
    </script>

  9. NS
    October 7th, 2007 19:22
    9

    I made the changes as instructed above and still got text in blog. See codes below. Looks like its not working. Can you please advise?

    <script type=”text/javascript”><!–
    ch_client = “xxxxxxxxx”;
    ch_width = 468;
    ch_height = 180;
    ch_color_border = “000000″;
    ch_color_bg = “000000″;
    ch_color_title = “FFFFFF”;
    ch_color_text = “FFFFFF”;
    ch_non_contextual = 1;
    ch_default_category = “81″;
    var ch_queries = new Array( “xxx”, “xxx”, “xxx” );
    var ch_selected=Math.floor((Math.random()*ch_queries.length));
    if ( ch_selected < ch_queries.length ) {
    ch_query = ch_queries[ch_selected];
    }
    //–></script>
    <script src=”http://scripts.chitika.net/eminimalls/mm.js” type=”text/javascript”>
    </script>

  10. admin
    October 7th, 2007 23:06
    10

    You should use something like below:

    &lt;script type=”text/javascript”&gt;&lt;!–
    ch_client = “xxxxxxxxx”;
    ch_width = 468;
    ch_height = 180;
    ch_color_border = “000000″;
    ch_color_bg = “000000″;
    ch_color_title = “FFFFFF”;
    ch_color_text = “FFFFFF”;
    ch_non_contextual = 1;
    ch_default_category = “81″;
    var ch_queries = new Array( “xxx”, “xxx”, “xxx” );
    var ch_selected=Math.floor((Math.random()*ch_queries.length));
    if ( ch_selected &lt; ch_queries.length ) {
    ch_query = ch_queries[ch_selected];
    }
    //–&gt;&lt;/script&gt;
    &lt;script src=”http://scripts.chitika.net/eminimalls/mm.js” type=”text/javascript”&gt;
    &lt;/script&gt;

  11. NS
    October 7th, 2007 23:58
    11

    Hi,

    I tried using the exact same code but I am am still getting the text in the box. Doesn’t seem to be working well. Thanks for your help anyway.

  12. admin
    October 8th, 2007 00:42
    12

    How do you put in the ‘box’?

  13. How to Display Elements (Ads) Only On (Or Only Not At) Individual Single Post Item View » My Digital Life
    October 10th, 2007 12:33
    13

    [...] cond=’data:blog.pageType == “item”‘> Parsed Google AdSense Ad Code (guide to parse the HTML code of AdSense JavaScript with escape character) [...]

  14. Kima
    October 27th, 2007 15:02
    14

    But changing the code… won’t that be against the Adsense Policy? I heard that Google is pretty strict about changing ANYTHING within its code, be it just the ASCII character as such… If you ask, me, I guess I’m not willing to take that risk :)

  15. james
    December 4th, 2007 17:38
    15

    how to send a with dis

  16. www.mobile2fun.com
    February 7th, 2008 02:55
    16

    Can I Display adds from google and adbite from my single website?

  17. » 6 Trucchi e consigli per Blogger Geekissimo
    February 13th, 2008 19:00
    17

    [...] la pubblicità: Per inserire la pubblicità dove vogliamo basterà modificare il template seguendo queste istruzioni, non è un lavoro molto difficile. Usare Feedburner: Ottimo servizio online per la [...]

  18. Gurji
    February 19th, 2008 23:26
    18

    Here is my adbrite code and i have made the changes although they do not work.

    Here is the adbrite code, unchanged from their website - could you please help me make the changes necessary to get it up and running:

    var AdBrite_Title_Color = ‘E1771E’;
    var AdBrite_Text_Color = ‘666666′;
    var AdBrite_Background_Color = ‘FFFFFF’;
    var AdBrite_Border_Color = ‘FFFFFF’;

    Your Ad Here

    Thanks - great article by the way, spot on, just what bloggers are looking for.
    Keep up the good work!

  19. admin
    February 20th, 2008 00:02
    19

    Using simple above should works. Try again.

  20. admin
    February 20th, 2008 00:04
    20

    Try to use Escape HTML Parser here:

    http://www.blogcrowds.com/resources/parse_html.php

  21. Free Blog Templates
    March 18th, 2008 14:45
    21

    Here’s another great resource as well. It works for all javascript ad codes including Adbrite, Chitika, AdSense, and others.

    http://www.eblogtemplates.com/blogger-ad-code-converter/

    It replaces all the characters Blogger gives you an error message for.

  22. mario
    April 26th, 2008 14:07
    22

    i have put to my blog at http://siputurbo.blogspot.com it seem not really happen and i`m still wonder why…because i`m use adbrite adv,when i`m convert code and then paste it….it have display but have a word written google adsense,actually i`m use adbrite…you can see in my blog at that add….anyone can help me??or this normal??

  23. Marcel
    April 29th, 2008 02:52
    23

    This does not work. It ends up displaying thr HTML as plain text in the browser. Why is blogger doing something so crazy ? Why do they they have to complicate something as simple as HTML ?

  24. Chitika Review
    May 2nd, 2008 06:36
    24

    Marcel, can you post the code that you used?

  25. mario
    May 3rd, 2008 02:02
    25

    After have adv on my page..then when i open today all already gone…where is`t??? my blog still at http://www.siputurbo.blogspot.com can anyone plz help me???

  26. Make Money from Blogs » Blog Archive » How to parse Adsense code to add within the Blogger template
    May 28th, 2008 11:08
    26

    [...] adsense code in greater clarity, explaining the need of why this change needs to be done. Read this article (link) for more details: If you try to insert any Google AdSense, AdBrite, AdEngage and any other JavaScript based ad [...]

  27. mobile
    August 8th, 2008 00:47
    27

    thanks.. was stuck with adbrite code…

  28. Freeware symbian java downloads
    August 23rd, 2008 14:18
    28

    Thanks for great tips.I am not sure about what you said for violation of adsense TOS.Are you sure its ok?

  29. watch tv show episodes online
    September 19th, 2008 02:20
    29

    Hi there, I found the above post very useful and I put adsense code within every post on my blog. This is very cool. I definitely recommend people who haven’t done this to try it because you will earn more. I have another question–do you have any advice for putting ebay affiliate rss feeds inside posts. I want to do it manually so that the feeds are relevant and correspond to what each particular post is about. And I only want a few posts to have the links. Do you know of any way to “parse” javascript so it can be read in a blogspot post?

    Thanks!!

    Chris

  30. Aman
    September 19th, 2008 20:33
    30

    changing “” to &lt & &gt. is it against adsense TOS?

  31. Lym Relampagos Ongoy
    October 14th, 2008 19:53
    31

    Your tips are very useful. thankx a lot…

  32. adit
    October 26th, 2008 17:39
    32

    nice tips!

  33. Javier
    November 18th, 2008 19:41
    33

    Thank you, great help!

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.
Custom Search

New Articles

Incoming Search Terms for the Article

The processing instruction target matching "[xX][mM][lL]" is not allowed. - Adbrite hack - google adsense javascript - download soce code java untuk google adsense - Blogger HTML code - adbrite blogger gadget - blogspot adbrite - adsense javascript - add adsense inside post - hack adbrite - javascript adsense - javascript in blogspot - advertisement html code - javascript on blogger - adbrite ads during post - adbrite sample code for full page add - adbrite blogger - add adsense to blogger template - add adsense to blogger html code - adsense parse - blogger html error - blogger how to html code - blogger template javascript - codigo html por musica no blogger - como posta java script no blogger - editing font size of google adsense - error with java add on blogger - google ads javascript - html put ads between every 5 posts - html code for advertisement - HTML/JavaScript para blogger - html ad code - javascript code sample ad - marillion javascript blogger - parse adsense code blogger - RSS feed javascript ads - The processing instruction target matching "[xX][mM][lL]" is not allowed - what is ads html code - javascript example - adbrite dynamic content such as forum - adding adbrite code in blogspot - adicionando elementos no html com javascript - adsense - adsense code javascript - Advertising HTML Code - block adbrite mac - blogger, html code - blogger add html javascript in post - codigo html para blog - coding google adsense -