Blogger not compatible with AdSense managed ads?
Lately I have been switching the standard AdSense ads to the new managed ad units on both of my blogs (this one and blog.trade-radar.com). Some of these ads are coded directly in the blog template rather than inside a Blogger Gadget or Widget. A good example of where this kind of coding is required is the sliding ad panel that rises from the bottom of the browser window.
I have also been rolling out a redesign of the TradeRadar blog template. The redesign has required me to make a number of other kinds of changes directly to the template code itself.
Just this week, however, it seems like Blogger has started evaluating Google AdSense code and making undesired changes whenever I save the template.
This is actually the second phase in an aggravating series of events related to inserting AdSense code directly into the blog template.
Problem #1 --
The first problem I encountered had to do with the symbols for Javascript comments. When copying the ad code from the Google AdSense site, the variables that define the ad parameters are surrounded by Javascript comment symbols. Leave the comments in and the ad doesn't work. Take the comments out and the ad works fine.
This seems to be a Blogger situation only. Paste the standard ad code into any web page and it works fine with no changes. Paste the ad code into a Blogger template and it doesn't work.
The solution I have used to date is to delete the comments. Unfortunately, this now leads to the second problem.
Problem #2 --
Blogger doesn't recognize the format for managed ad units. If the ad unit code is surrounded by comment symbols, Blogger will not mess with it. As described above, however, I have found that I needed to remove the comment symbols in order to make the ad code work.
When the ad unit code is not surrounded by comment symbols, Blogger interferes with the code, trying to add a value for the AdSense publisher ID into the google_ad_client variable. This, of course, messes up the ad completely.
The workaround --
I took the Javascript variables that the managed ad needs and saved them into a Javascript file. I uploaded the file to one of my web sites. Then I used a simple script tag to retrieve the file immediately before the Google script tag that activates the ad.
This fixes the problem for now. Of course, it requires that you have your own domain where you can store your Javascript file.
Is anyone else encountering this problem? Do you have a different or better workaround? Feel free to leave a comment and let us know how you are handling this situation.
Subscribe to OpenLinkz by Email


