Computers, Gadgets and Beyond!

Converting from Google AdSense for Content to the new AdSense Units

March 05, 2008 By: webmaster Category: Website

The old style Google AdSense for Content HTML code had a lot of information about the look and feel of an ad. Half a dozen colour values for background, foreground, links, text etc along with ad size, ad type and of course your ad code and perhaps channel code. Bit of a mess trying to keep track of everything, even with helpful addons like Adsense Manager (which sucks after v2.5). So Google has moved more of the fiddly bits into their AdSense administrative interface and the new thing is called an AdSense Unit. Old style HTML code:


google_ad_client = "pub-55555555555555555";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "image";
google_ad_channel = "555555555555";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "7CC135";
google_color_text = "000000";
google_color_url = "";

compared to the new:

google_ad_client = "pub-5555555555555555";
google_ad_slot = "55555555555";
google_ad_width = 160;
google_ad_height = 600;

The other parts of the puzzle, including the Google javascript call, remain the same. As you can see, bare bones is your ad code, a new thing called an ad slot and a width and height. The latter two to speed up page rendering, as the javascript code can tell the browser how much space it will consume before loading the actual ad.

Now, if you have a lot of these old style ads that you would like to convert then Google provides a conversion tool. And you want to convert, as the Google interface for keeping track of ad types and their look and feel is a step up from doing it by hand or by third party tool. and it only takes a minute per ad to convert, ish.

To convert, go to your AdSense page and select AdSense Setup followed by Manage Ads. Around the top you will see a link intuitively called import your old AdSense code. Hit that, and you will be greeted with a page containing a big text area and a small one. Now copy the HTML code (well, javascript-code) from an old ad into the big area and write a useful name for that ad into the small area and hit the button. You do not need to copy anything other than the javascript variables, they are what differentiates one ad from another.

Note that if the copy HTML code part above was greek to you then run through Google’s explanation before you continue.

Now for the stupid part which Google really should fix. If there is an error in the HMTL you paste in you will get the very unfriendly error The snippet is invalid. With absolutely no explanation on what is wrong. And the useless part is that this syntax checker is actually more strict than the one Google uses in real life so the code in question may show a completely valid advert on your web page but still be rejected by this tool. Now, the most common problem here is that quite a few tools that autogenerate AdSense ads, including Adsense Manager for WordPress, will forget to print some of the values. See the example above, where the last variable google_color_url has an empty string as value? This works fine in real life, especially since it’s an image only ad in the first place. But the converter will see this as a problem and give you the error mentioned above. So if you are absolutely sure you have pasted in the correct code and still get an error then make sure all the variables actually have proper values. Changing "" to "000000"
in this case and the code passes the test and you have a new unit. 

Now you can just use the new and improved style on your web pages, and if you want to change the look and feel of an ad then you can do so through the Google AdSense interface.

 Is it worth it? Not really just for the current functionality, but you never know when the old style stops being supported or when only new style ads get a new and flashy feature that mesmerizes the ad clicking crowd. So get on the band wagon now, it’s not difficult.


2 Comments to “Converting from Google AdSense for Content to the new AdSense Units”

  1. Wow, it’s a great theme

  2. Presumably this is just a link troll, but what the hey. 🙂


Leave a Reply