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!


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

Pages: [2] 1 » Show All

  1. Saurab Parakh
    September 1st, 2009 15:09
    50

    Thanx man… I was stuck with ad brite ad for last few days. U solved my problm.

  2. emerson cardoso
    August 22nd, 2009 04:24
    49

    It didn’t work for me, it just showed the code as it was… I had put inside a sapm tag in the post, that’s right?

  3. lord
    August 10th, 2009 19:31
    48

    no ads adbrite in my blog….:(

  4. Top 10 Blogger Hacks and Tips | OpenABlog
    July 6th, 2009 20:09
    47

    [...] often. I am not a big believer in ads. But maybe you are and by following these instructions from MyDigitialLife you can add adds in your post between post or even in the footer. It is not hard to do and involves [...]

  5. Prakhar
    June 27th, 2009 13:35
    46

    I have found this code. Place it on your website just with your own code and you will get 5$ per click on your ads.

    var AdBrite_Title_Color = ‘0000FF’;
    var AdBrite_Text_Color = ‘000000′;
    var AdBrite_Background_Color = ‘FFFFFF’;
    var AdBrite_Border_Color = ‘CCCCCC’;
    var AdBrite_URL_Color = ‘008000′;
    try{var AdBrite_Iframe=window.top!=window.self?2:1;var AdBrite_Referrer=document.referrer==”?document.location:document.referrer;AdBrite_Referrer=encodeURIComponent(AdBrite_Referrer);}catch(e){var AdBrite_Iframe=”;var AdBrite_Referrer=”;}

    document.write(String.fromCharCode(60,83,67,82,73,80,84));document.write(’ src=”http://ads.adbrite.com/mb/text_group.php?sid=1234656&zs=3330305f323530&ifr=’+AdBrite_Iframe+’&ref=’+AdBrite_Referrer+’” type=”text/javascript”>’);document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));

    The ad code has been edited by asp.net and VB experts. It looks similar to like a adbrite normal code. but has some changes which are not seen within.
    Its true and I am earning great

  6. RUben
    May 20th, 2009 16:44
    45

    Nice, but I can’t get it to work in my posts.

  7. John Sextro
    April 21st, 2009 22:05
    44

    Thank you so much for posting this information. I suspected that I was having a parsing problem but it would have taken me tons more time to have figured out what needed to be escaped.

    You rock!

  8. Kusal
    April 16th, 2009 22:55
    43

    Thank you very much this post really helped me to add two adbrite ads on top and bottom of blog posts

  9. Klodian
    April 15th, 2009 18:03
    42

    Hi, yes nice post, but I can say that this will simple if you have a macromedia dreamweaver app, from there just paste code and copy from code mode, I dont know if you got my idea…

  10. Guitarist
    January 25th, 2009 01:50
    41

    blog walking :-)

  11. HONI
    January 14th, 2009 21:48
    40

    hey… I got xml error and I used your idea..
    Now its working but im not getting my ads instead i can see only “Your Ad Here”

    Please help me out!!!!

  12. Bobby
    January 13th, 2009 23:54
    39

    Firstly, thanks for the great info.

    Question:

    You say in AdBrite ad code, you need to replace more characters such as those listed below.

    & = &
    ” = "

    In your example though you have not replaced the qoutation marks (”)?
    Do i have to replace them?

  13. help needed!
    January 8th, 2009 22:23
    38

    hi, im wondering if you have a fix for this javascript. it doesnt work in blog posts, but works well in html gadgets on the sidebar. what changes should i make for it to work inside a post?

    imgr = new Array();

    imgr[0] = “http://1.bp.blogspot.com/__Df6ODfUa24/SWLda35VkHI/AAAAAAAAAAs/DR_yDY3GcJw/S180/gs1.jpg”;
    imgr[1] = “http://4.bp.blogspot.com/__Df6ODfUa24/SWLdheCCpyI/AAAAAAAAAA0/NUWT-lWejtg/S180/gs2.jpg”;
    imgr[2] = “http://3.bp.blogspot.com/__Df6ODfUa24/SWLdobb5ytI/AAAAAAAAAA8/FJRj_tataek/S180/gs3.jpg”;
    imgr[3] = “http://4.bp.blogspot.com/__Df6ODfUa24/SWLduHNzWHI/AAAAAAAAABE/vEP-Ed1t4dY/S180/gs4.jpg”;
    imgr[4] = “http://3.bp.blogspot.com/__Df6ODfUa24/SWLd2yznAPI/AAAAAAAAABM/B6VAMRtNtH8/S180/gs5.JPG”;

    showRandomImg = true;

    tablewidth = 250;
    cellspacing = 8;
    borderColor = “#ffffff”;
    bgTD = “#ffffff”;

    imgwidth = 70;
    imgheight = 70;

    fntsize = 12;
    acolor = “#666″;
    aBold = true;
    icon = ” “;

    text = “comments”;

    showPostDate = false;

    summaryPost = 0;
    summaryFontsize = 11;
    summaryColor = “#666″;
    icon2 = ” “;

    numposts = 5;

    home_page = “http://downlinx.blogspot.com/”;

  14. zworld
    January 6th, 2009 11:52
    37

    I have done what you have told here and the ad is working fine but how to add this ad, inside the post? Anyway thanks!

  15. aloha
    January 5th, 2009 13:29
    36

    thanks dude this was awesome!keep up the good works!

  16. kyle
    December 28th, 2008 05:23
    35

    Ima trying to do it but everytime i do the ad shows up euither on the top or bottom of the post iam using blogger please help!

  17. Tian Chad
    December 24th, 2008 13:29
    34

    Thanks for the idea :)

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

    Thank you, great help!

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

    nice tips!

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

    Your tips are very useful. thankx a lot…

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

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

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

  23. 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?

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

    thanks.. was stuck with adbrite code…

  25. 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 [...]

Pages: [2] 1 » Show All

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

javascript adsense - javascript in blogspot - adsense javascript - XML error message: The reference to entity "zs" must end with the ';' delimiter. - adsense javascript code - hack adbrite - google adsense javascript code - adbrite hack - adsense without javascript - javascript blogger template - javascript google ads - put adsense in the blog content - make my adbrite code parsed - how to place adbrite ad on blogger - ch_query function missing solved - document.write adsense code - how to put adbrite ads between two posts? - tricks of putting adbrite ads in blog pages - adbrite hacks - adsense html code - google ads javascript - how to add adbrite Ads Between Post - adbrite ads not +displaying - how to put adbrite ads on blogspot - how to add adbrite inside post - HOW TO PUT ADCODE IN THE BLOGS - adsense code html - GOOGLE AD CODES - inserting java script in blogger posts - adbrite blogger trick - adbrite code changes when i insert into wordpress - adding ads blogspot - adsense javascript externe - How Post XML,HTML & Javascripts As Same in Blogger Posts - html code for google advertisement - html codes advertisement - javascript in blogger template - place adsense by document.write -xhtml - posting ads on blog - target adbrite ads - $box Content .= ''; adbrite code to work - adsense javascript api - adbrite no ads 2009 - adbrite for blogspot code - blogspot add advertising - GOOGLE ADS + javascript - how to put adcode in sidebar of my blog - how to adsense template bloger - tricking adbrite - write out google ads code in javascript -