Welcome, visitor! [ Login | Sign Up ]

How to Embed Ad Code Anywhere in Your Blogger Template



Have you ever tried to insert javascript ad code directly into your Blogger Template and it just wouldn’t work? Ok, everyone in the room can put their hands down now. This has always been a huge problem for blog authors using Google Blogger looking to monetize their site since almost all ad code contains javascript.

So why is this so darn difficult to do? The problem in the past was that Blogger users wanted more control over where and how frequently their block of ad code (usually AdSense) appeared. The Blogger Team listened to their customers and created an easy to use feature that allows you to setup AdSense in your individual posts with a simple checkbox selection.

Typical Blogger Error Messages

That’s great for most people but the places where you can insert widgets are rather limited and not as flexible as you’d like. So what if you want to put AdSense, AdBrite, Chitika or any other sort of javascript-related code elsewhere on your blog without having to use a widget? The answer in the past would be, “It’s just not easy”.

You would paste the Google AdSense, AdBrite, Chitika or any other javascript ad code into your xml Blogger template only do get an error like:

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 another really cryptic error message like:

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 content of elements must consist of well-formed character data or markup.“.

In fact, more recently the Blogger xml parser seems to allow javascript code in your template without displaying an error message at all. You think all is well only to discover when you view your blog that nothing actually gets displayed. Grrr.

Using the Blogger Ad Code Converter

So how can I get around this and easily use ad code or any javascript inside my xml Blogger template? Introducing, the Blogger Ad Code Converter by eBlog Templates. This simple tool will take any block of javascript or html code and replace the characters that Google Blogger ignores with the correct ones. Here’s a real life example. Say I want to put a Google AdSense 468 x 60 banner ad into the header of my blog but there’s no widget to use. You’d have to manually go into AdSense and create a new ad unit to get the code. Here’s the result:

<script type="text/javascript"><!--
google_ad_client = "pub-6044026340890176";
/* 468x60, created 3/17/08 */
google_ad_slot = "3105157606";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="https://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

Now if you just pasted that ad unit code directly into your Blogger header you’d get an error or it just wouldn’t work. Most people would think Blogger was broken or wonder if it’s something they did when in fact it’s neither. The new Blogger uses xml which is much more strict and requires certain reserved characters like > < or & to be converted into xhtml entities. Here’s what your ad code needs to look like in order to work properly:

&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-6044026340890176&quot;;
/* 468x60, created 3/17/08 */
google_ad_slot = &quot;3105157606&quot;;
google_ad_width = 468;
google_ad_height = 60;
//--&gt;
&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;
src=&quot;https://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
&lt;/script&gt;

This only took me a few seconds to convert since I used the free and easy Blogger Ad Code Converter. There are actually posts out there that explain how to do this manually but who wants to take the time searching and replacing each character when you can convert unlimited sized ad code blocks with only one click?

After you’ve converted your ad code, paste it into your template and it should now work. Obviously before you make any changes to your Blogger template, it’s a good idea to back it up. You never know when you might make a mistake or revert to a previous version. Once you’ve done that, give the Blogger Ad Code Converter a try for free!

What Other Code Can it Convert?

Actually this tool is quite powerful and can be used for encoding any HTML or javascript into XHTML entities. Some popular javascript ad codes that are converted are AdSense, Text Link Ads, AdBrite, LinkWorth, Chitika, Amazon, and more. Another good use is if you need to post a large block of HTML or javascript code into your blog post you can just use this tool.

Technically, it does so by replacing the reserved HTML characters with their XHTML equivalents. It’s basically a simple HTML Encoder that automatically replaces all HTML special characters like <, >, & into entities &lt;, &gt;, &amp;.

Please note: If you are using this tool to convert Google AdSense code you don’t need to worry about breaking the AdSense program policies. This tools is just encoding reserved HTML characters into usable XHTML entities for xml Blogger. When you paste the code into your blog, save it, and then view the source code for the page, you’ll notice your AdSense code is displaying as it was originally written. This modification will not alter the functionality of the code at all, and ensures that it will be displayed within Blogger correctly.

Ready to super charge your blog? Check out our professional premium blogger templates or make money by joining our blog affiliate program!

If you like this post then please consider subscribing to our eBlog Templates RSS feed. You can also subscribe by email and have new templates and articles sent directly to your inbox.




Trackbacks

  1. Blogger Ad Code Converter | H_acktivis_T on September 5, 2008

90 Responses to “How to Embed Ad Code Anywhere in Your Blogger Template”




   
andy on Mar 19, 2008, 2:09 am  

wow… interesting article
I must try to apply to my blogs..
thank for useful article


   
sameer on Mar 21, 2008, 1:34 am  

thanks for useful article and information 😀 how to post ads middle of the article?


   
Agent 001 on Mar 21, 2008, 1:47 am  

Damn good info.It was very helpful.


   
David on Mar 21, 2008, 2:20 am  

That’s a good idea but I don’t think you can. Did you try pasting the ad code directly into your blog post? You’ll need to paste it in using the html editor.


   
paulo araujo on Apr 1, 2008, 9:45 am  

Excelent

The subjects of this blog are of great quality

Paulo Araujo
rio de janeiro – Brazil


   
Webhosting Tips on Apr 10, 2008, 3:48 pm  

One of the most informative blogger tutorials I’ve come across so far. Thank you.


   
jim on Apr 10, 2008, 4:20 pm  

Definitely not working for me either…


   
David on Apr 10, 2008, 6:51 pm  

@jim, what is not working for you? What error message do you get?


   
booblemoofie on Apr 21, 2008, 12:29 am  

same here, no results when i click convert ad code i tried it 20 times already! 😥 😥
please fix this i really really need this are any other websites offering the same


   
mario on Apr 25, 2008, 10:04 pm  

i have put to my blog at http://siputurbo.blogspot.com it seem not really happen and i`m still 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?? 🙁


   
senolyagnl on May 27, 2008, 6:13 am  

hii

this site is wonderfull… i have took something. thnx a lot.


   
veysi on Jun 24, 2008, 7:44 am  

excelent, but i don’t do 😛


   
kapalic on Jun 30, 2008, 10:29 am  

Excellent tool! Moreover..it’s free!!

You r doing an wonderful job buddy!! 😉


   
kapalic on Jul 6, 2008, 9:59 am  

will it work if I paste the adsense code in the post body after converting it here? That would be really nice to show ads end of the posts!!


   
EyeSoft on Jul 19, 2008, 3:08 pm  

thx for help David 😀


   
girlguide on Jul 26, 2008, 4:28 pm  

Thanks a million. 💡 I’m only sorry I did’nt read this article before the 3 hours 😡 I spent trying to figure out what the heck was going on why my ads were not being displayed. 🙄 Thanks and thanks again 😀


   
vacom on Aug 1, 2008, 1:35 am  

I like this tools!

😉
http://www.varietyarticle.com


   
patlak on Aug 2, 2008, 12:53 am  

thanks, i trying it


   
Synnta Claus on Aug 4, 2008, 9:29 pm  

Hi, I tried using this AdConverter on a new blog that I have created for my job. So, when I pasted the converted template onto my new blog template, this message pops up. “Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: Reference is not allowed in prolog.”
I do not have any problems with my personal blog that I have been using for quite sometime. Only this new one that I have created.

Desperate help needed. 😥


   
HOT INSTANT CASH on Aug 6, 2008, 11:12 pm  

   
wangxtra-top-blog-directory on Aug 23, 2008, 9:04 am  

gosh…. you safe me… thanks a lots 😉


   
tropicwater on Aug 24, 2008, 1:14 am  

What an brilliant idea. I should try this, thx dude.


   
deogw on Sep 3, 2008, 10:14 pm  

This first time I Comment,,

Thx a lot,,


   
Siaar Group on Sep 23, 2008, 12:45 am  

Really a very good article which is most required by the blogger users.


   
Suzan on Sep 24, 2008, 5:58 am  

Hi David,
I’m getting hard time here. Please help me. I have a new blog setup at http://costometic.blogspot.com/ and I can’t figure out ‘where’ to paste the Amazon Code.
I have two Amazon codes that I need to insert in my HTML file –
1. Amazon Contextual Links
2. Amazon Crousel Widget
The problem is that I don’t understand where should I pate the converted code in the XML html file. In beginning, I see all the CSS stuff and thereafter, it shows the XML elements. I have tried pasting the code in just after the tag, I have tried pasting it in middle, I have tried pasting it at the bottom just before tag, I have tried pasting it just above tag. But the Amazon Contextual Links simply wont show up.
Apart from this, I have no idea how to show the Amazon Crousel Widget after each post. I see this is nothing like WordPress Blog I have setup on http://www.costometic.com
It was easy handling WordPress since it has all the PHP coding. But Blogspot has XML coding and I’m going nuts.
I really need your help on this subject.
I appreciate your help.

Regards,
Suzan.


   
hello on Oct 4, 2008, 5:57 am  

😯 😯 😯 😯 😯 😯

HELLO FRIENDS MEET WORLD’S FINEST MATRIMONIAL WEBSITE
http://www.speedmarry.com multilanguage and 100% free website
meet me on http://www.speedmarry.com

thankyou,hello ❗


   
hello on Oct 4, 2008, 5:59 am  

hello hello world’s finest matrimonial website http://www.speedmarry.com


   
probloggerdesign on Oct 6, 2008, 2:04 pm  

wow
i love it


   
Do you need an help on loan on Oct 27, 2008, 4:52 am  

Am here to help you out on a problem when you are. What kind of loan do you want i will give it to you. If you need it just contact me on mr.juancompayltd@gmail.com.
Thanks
My regards
Mr Juan


   
me on Nov 16, 2008, 8:46 pm  

i’m using the converter but it’s not working..the error still come out 😥


   
ISee on Nov 20, 2008, 7:06 pm  

Got it!


   
Andre on Nov 26, 2008, 10:53 pm  

Someone needs to take care of these spammers. And that speedmarry faggot and the Loan guy, understand this, we are NOT GOING TO VISIT you stupid sites and we are NOT GOING TO SEND you email for loans. It clearly shows that both of you suck and need to get a life. You spamming cunts.


   
venkat on Dec 2, 2008, 5:00 am  

i tried ur template it is very good it is working fine
but i failed how to add adsense any where in the template. i still trying……………..

FREE Link directory
http://linkswebs.co.cc


   
moneyholic on Dec 21, 2008, 2:19 am  

Yes.. after i change my template from here, many problem about message :
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.

until now i cant put code from google webmaster tool. but now ill check with your tool.

its very nice information


   
moneyholic on Dec 21, 2008, 3:05 am  

wow success.. thks a lot


   
Professional Lab on Dec 30, 2008, 4:27 am  

Thanks a lot! Really itz very very helpful…. I was madly looking for it.
Thumbs Up for YOU !!!


   
Janvi D on Jan 13, 2009, 11:27 pm  

Hi,

If you have really hard time figuring it out, you can have someone do all the work for you at a cheap price. Try posting a free project for outsourcing at: iAmAnArtist.com

you can get freelance programmers to design and create xml / blogger templates for you.


   
OptimusTronic on Jan 22, 2009, 8:26 am  

thanks!


   
clickerz on Jan 24, 2009, 7:29 am  

Thanks you very much, I learned some insights.

More Power


   
Samrat on Jan 26, 2009, 6:36 am  

Good article about template hacking. Nice, really nice. Thanks for this help..


   
hajaf on Feb 18, 2009, 10:14 am  

Thanks for tips but i still have a problem on my blog
http://blo-temp.blogspot.com/


   
irhille on Feb 22, 2009, 2:11 am  

thank you for the great info.
i got an error using js in blogger.
but with your converter it ease my pain.
i’ll use your converter next time.
cheers to you.


   
Analekto on Mar 15, 2009, 12:12 pm  

Really nice article I had to go through some googling back then when I start blogging so I can add adsense on my blog. In case anyone is interested I have written an article that describe how to add two ad units anywhere in the blogger post body. You can find it here


   
cheth on Mar 17, 2009, 10:49 pm  

wow this is what i was looking for my new template! I was struggling with those adsense errors!


   
Balu on Mar 18, 2009, 9:11 pm  

I found your deep knowledge in posts, I congratulate in your efforts.
I have something to specify–
When I checked the page source view of non-Blogger site the adsense code looks like this-

And that of Blogger sites it is as follows:

The difference I felt is in non blogger site the ad code contains detailed color and width formats and with padding statements.

If the non blogger ads code put in blogger post it will work fine.

So the question is – Is non blogger site altering the adsense code or are they getting the code directly from adsense?

And one more thing Adsense clearly specifies the ad should not be placed inside a float box or frames etc.

The technics you explained in this pot can I use it to show ads inside the post?


   
Balu on Mar 18, 2009, 9:14 pm  

Sorry I am putting my comment again correctly:

I found your deep knowledge in posts, I congratulate in your efforts.
I have something to specify–
When I checked the page source view of non-Blogger site the adsense code looks like this-

And that of Blogger sites it is as follows:

The difference I felt is in non blogger site the ad code contains detailed color and width formats and with padding statements.

If the non blogger ads code put in blogger post it will work fine.

So the question is – Is non blogger site altering the adsense code or are they getting the code directly from adsense?

And one more thing Adsense clearly specifies the ad should not be placed inside a float box or frames etc.

The technics you explained in this pot can I use it to show ads inside the post?


   
JOE on Mar 23, 2009, 12:11 am  

nice…..


   
Balu on Mar 26, 2009, 11:16 pm  

no one to answer, is it a deserted page or what?


   
pangeran on Apr 2, 2009, 5:21 pm  

gooooooooooood information..