Sunday, June 13, 2010

Adsense Code Convertol Tool

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

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:


<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="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

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?