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


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




   
siegfried ehmke on Apr 6, 2009, 2:00 pm  

I’ve installed the new template and set up adsense but where do you get the sponsor ads and how does that work? I’ve seen the videos on how to paste the codes already.


   
小新 on Apr 13, 2009, 7:16 am  

Your tool solved my problem.

Blogger’s HTML converter is headache.

btw: I answered the question by your tools
http://www.google.com/support/forum/p/AdSense/thread?tid=4a145fba9be125e2&hl=en


   
zeebigtourist on Apr 14, 2009, 6:20 pm  

As usual, as helpful and as informative as ever.

Especially the converter part! *gushing* Hee hee!

Thanks David!

Cheers!

ZBT
http://www.zeebigtourist.blogspot.com


   
kojj.com on Apr 17, 2009, 7:32 am  

thanks for the great info i wanna try on by blogspot now once again thanks


   
joe on Apr 24, 2009, 10:20 am  

I should have come to this post earlier. there are 100 of people try to solve this ad-not-show at google blogger group but nobody has any solution, they are just guessing around. I should spread the words about your blog. Thank so much for this.


   
Blenk on May 3, 2009, 12:53 am  

Good articles. Thank you so much.


   
Rajesh Kumar on May 31, 2009, 10:40 pm  

Cool…..
searching for no of days ….
it’s working in my blog ….
Fun Evil


   
WareHouse on Jun 5, 2009, 4:35 am  

Nice Articles … Thank You


   
Scorpion on Jun 22, 2009, 10:26 pm  

i like this. It is cool


   
technomedic on Jun 29, 2009, 10:57 am  

Thanks for the great Adcode converter
I was searching for it for quite some time. But unfortunately I got it when my Adsense account was blocked……alas now running my blog without any Ads…..and trying to get another account
DiGi-PASSION (http://technomedic.blogspot.com)


   
sajid on Jul 30, 2009, 10:14 pm  

I have a problem any one please help me.
I add google adsens in the posts of my blog but there the add not appear when i save the template.


   
sajid on Jul 30, 2009, 10:17 pm  

I have a problem any one please help me.
I add google adsens in the posts of my blog but there the add not appear when i save the template
please tell me what i to do.
my email is
naraz_nahi_huna@yahoo.com


   
Shail on Aug 3, 2009, 10:47 pm  

Thanks for this useful information.
I got my problem solved.
Thanks.


   
deen on Aug 28, 2009, 1:49 pm  

a lot thanks to owner because i can insert my google ads and my blog was easy crawl by google search engine from seo for traffic


   
Skincare on Nov 4, 2009, 5:37 pm  

Thanks a lot. I have converted succesfully and using on my blog.


   
Net BD on Feb 18, 2010, 12:38 pm  

New Page 3


   
Doctor5 on Feb 22, 2010, 7:38 am  

Nice article, It has very informative material in it. This thing is very new for me and I also glad to read this article about add.
Thanks a lot…


   
Long Hair Tips on Mar 14, 2010, 8:06 am  

Wow it is so mysterious, fabulous and mind blowing post! I liked the story and I will share it with my friends, I think they will lied it so much as I did. I think so it is good place to gain a lot of knowledge as much as more experience from such type of educational Blogs. Indeed I gave the link to you blog to some of them and they are now your constant readers. Thanks for sharing and I hope you will be here for giving us more information in the future. Once again thanks for cooperation…


   
Blazing Wallpapers on Apr 5, 2010, 3:22 am  

I wanted to know how to post html/xml codes without having to either paste it as a picture or remove some part.


   
akalil akhtar on Aug 2, 2010, 12:30 pm  

thanks very much for your article… now i can put my ads code to my blog.


   
linda chen on Aug 3, 2010, 1:22 am  

goos


   
Lokesh on Aug 10, 2010, 12:45 am  

Truely Awesome!!!

I just now tried and it’s working pefectly fine. Now my Adsense revenue should increase. Thanks a lot for posting Great Stuff.


   
gue on Sep 30, 2010, 8:26 am  

whoa! this is what i looking for, many tanx


   
ziaur on Dec 11, 2010, 12:06 am  

Amazing Idea Boss.


   
jawad amin on Mar 2, 2011, 5:52 am  

Your template could not be parsed as it is not well-formed. Please make sure that all XML elements are closed properly.
XML error message: Open quote is expected for attribute “{1}” associated with an element type “style”.

how to remove this problem???


   
abhishek on Mar 13, 2011, 3:57 am  

this is modification of adsense code.
isn’t it a violation of their policies ?
and won’t this give us non paying public service ads ??
please reply…


   
John on Jul 18, 2011, 10:02 pm  

Your tool is really nice.. kudos..


   
Ariko D' Hagana on Nov 28, 2011, 6:03 pm  

Hello eblogtemplates.com

Wow…I was too late to know this information 🙂
but never mind, better late than not at all, right?
This article that you share is very useful and helpful for me. What you share here just like spread joy to many people… hopefully good things are always with you.

Keep Sharing
Ariko “http://kamidarisemua[dot]wordpress[dot]com”
Indonesia


   
mind power on May 9, 2012, 8:45 am  

thanks…excellent thanks 4 share the tools….


   
vipin on May 9, 2012, 11:33 am  

Is there a way to blend your ads exactly with your content?
Thanks for this share though!


   
sebastjan on Jun 4, 2012, 11:23 pm  

   
ussai on Jul 26, 2012, 10:23 am  

   
BIGRYANJ on Sep 1, 2012, 11:21 pm  

WOW REALLY HELPFUL AND CAN SOMEONE GO ON MY SITE


   
Tradition on Jan 7, 2013, 11:24 pm  

Thank you so much.


   
Ficri Pebriyana on Feb 24, 2014, 7:46 pm  

thanks,
nice post…


   
boim lee on Oct 8, 2014, 10:51 pm  

excellent tool, thanks for the article


   
jaringan komputer on Nov 28, 2014, 10:47 pm  

woww, article that you share is so useful and helpful for many new blogger, i have to try too for my blog


   
Saddam Hossain on Jan 28, 2016, 6:08 am  

really its important for us.


   
Nana on Feb 28, 2016, 7:49 pm  

Thanks, in the beginning I thought it’s break a rule of gg ads. but now I kknow that it can be done. : D

big thanks.


   
mbah PC on Oct 19, 2016, 11:09 pm  

very useful article and great benefit for my blog