Since this needs to appear just above the /body tag, you will probably need to make a new partial (as in .rhtml file) and then render it from each of these layouts: application, blank, simple, and noside. Of these application is the most important.
That partial should just include all the google analytics code, inside a big if. If you have the key, then show the code.
Here's how you'd get the card in that context:
Notes from Aaron and Lew taking about this 6/26//08:
The main thing you need to know for it is how to get the card from the cache, and the api is a little goofy there:
would be something like c=CachedCard.get_real('*ga_key'); key=c.content
wagn caches 'missing' cards now, so whether you have a key or not after the first lookup it won't cause a db hit.
Lew thinks helpers might be a better idea, largely because of performance considerations. So instead of rendering a partial from each layout, you would make a method call. You just put the method into wagn_helper.rb with all the above logic.
Lew's comment in
irc: fwiw partials always hit the disk & reparse each request, whereas helpers get compiled once per process startup.
--Ethan McCutchen.....Thu Jul 17 10:55:54 -0700 2008