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

ยปยปยป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 JavaScript 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 or gadget 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 engine.

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!

By | 2016-12-09T08:39:19+00:00 December 9th, 2016|Categories: Web Publishing|Tags: , |59 Comments

About the Author:

LK is a technology writer for Tech Journey with background of system and network administrator. He has be documenting his experiences in digital and technology world for over 15 years.Connect with LK through Tech Journey on Facebook, Twitter or Google+.
  • BW

    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

  • admin

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

  • BW

    Thanks for the reply

    I tried changing the ch_selected

  • BW

    try again

    I changed all the

  • Nawin

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

    Thanks

  • NS

    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&quot; type="text/javascript">

    </script>

  • NS

    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&quot; type="text/javascript">

    </script>

  • NS

    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&quot; type="text/javascript">

    </script>

  • admin

    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=&rdquo ;http://scripts.chitika.net/eminimalls/mm.js&rdquo; type=”text/javascript”&gt;

    &lt;/script&gt;

  • NS

    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.

  • admin

    How do you put in the 'box'?

  • 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 ๐Ÿ™‚

  • james

    how to send a with dis

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

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

    <!– Begin: AdBrite –>

    var AdBrite_Title_Color = 'E1771E';

    var AdBrite_Text_Color = '666666';

    var AdBrite_Background_Color = 'FFFFFF';

    var AdBrite_Border_Color = 'FFFFFF';

    Your Ad Here

    <!– End: AdBrite –>

    Thanks – great article by the way, spot on, just what bloggers are looking for.

    Keep up the good work!

  • admin

    Using simple above should works. Try again.

  • admin

    Try to use Escape HTML Parser here:

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

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

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

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

  • Marcel, can you post the code that you used?

  • mario

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

  • Pingback: Make Money from Blogs » Blog Archive » How to parse Adsense code to add within the Blogger template()

  • thanks.. was stuck with adbrite code…

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

  • 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

  • changing "" to &lt & &gt. is it against adsense TOS?

  • Your tips are very useful. thankx a lot…

  • nice tips!

  • Thank you, great help!

  • Thanks for the idea ๐Ÿ™‚

  • kyle

    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!

  • aloha

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

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

  • help needed!

    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&quot;;

    imgr[1] = "http://4.bp.blogspot.com/__Df6ODfUa24/SWLdheCCpyI/AAAAAAAAAA0/NUWT-lWejtg/S180/gs2.jpg&quot;;

    imgr[2] = "http://3.bp.blogspot.com/__Df6ODfUa24/SWLdobb5ytI/AAAAAAAAAA8/FJRj_tataek/S180/gs3.jpg&quot;;

    imgr[3] = "http://4.bp.blogspot.com/__Df6ODfUa24/SWLduHNzWHI/AAAAAAAAABE/vEP-Ed1t4dY/S180/gs4.jpg&quot;;

    imgr[4] = "http://3.bp.blogspot.com/__Df6ODfUa24/SWLd2yznAPI/AAAAAAAAABM/B6VAMRtNtH8/S180/gs5.JPG&quot;;

    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/&quot;;

  • Bobby

    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?

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

  • blog walking ๐Ÿ™‚

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

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

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

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

  • Prakhar

    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.

    <!– Begin: AdBrite, Generated: 2009-06-27 1:30:37 –>

    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+'&quot; type="text/javascript">');document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));
    <!– End: AdBrite –>

    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

  • no ads adbrite in my blog….:(

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

  • Saurab Parakh

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

  • TJ

    Thanks! Everything working great now.

  • Im new blogger, if I mix 2 advertisment, adsense and Adbrite

    whether they will reject and banned my blog?

  • rara

    nice info…thx

  • sureshnariya

    Perfect!Able to fix adbrite issue.

    Thanks,

    Suresh Nariya.

  • N Gage Games Review

    Nice information. i'll try now, and hope it works. Thanks for the admin.

  • rajil

    thank u.sir,its really useful.

  • PHSTREAM TV

    thanks, it works to my blog

  • Jebastin

    Hello admin,
    I've one doubt. Actually in my blog adsense account is waiting for approval.
    Without the approval of google adsense can i add the code with my pub ID????
    pls help me!

  • SE

    Thank you .. i tried my blog.. it's working good..

  • Deepak

    Hello!! I'm new to this blogger and i am not able to paste the code of amazon ads in the edit HTML tab given.. can you say where to place the code in it………

  • Anjali

    We want to put the ads in a popup box how can do that

  • Well it works pretty fine, but don’t it have any straight script which we can use.
    Using above script, fetches some errors which are unfixable ๐Ÿ™

  • OdishaJobs

    Hello
    Can any one tell me how to make custom google ad sizes. eg. 600*280

Pin It on Pinterest

Share This

Share This

Share this post with your friends!