guillermo, out of repose

Abstracting Analytics

In re-thinking the way I approach the JavaScript on my site, I’m def­i­nitely lean­ing towards cre­at­ing an ana­lyt­ics wid­get. I want to keep as much JavaScript as pos­si­ble out of my HTML. So, in lieu of the code that cur­rently sites at the bot­tom of any given page, I think I should do some­thing like this:

$(document).ready(function(){
OOR.widget.Analytics.init("Google", "UA-99999999-9");
     // other code
});

That would load all of the needed Google code, which would prob­a­bly exist in a name­space like OOR.widget.Analytics.Modules.Google. If, for some rea­son, I decide to go back to Rein­vig­o­rate (which pro­vides great data, by the way), I’d just add a new ana­lyt­ics mod­ule called OOR.widget.Analytics.Modules.Reinvigorate into the mix and mod­ify my call with the appro­pri­ate para­me­ters (but where would I make that change? Would I do it man­u­ally in my JavaScript file? Would I throw it in the head tag? Would I put all of that into a Word­Press plu­gin so I could han­dle the changes in the admin? And if I do cre­ate a plu­gin for that, how then would I man­age all of the other JS that should be han­dled once the DOM is ready to be manip­u­lated? Wid­getize the calls that need to go into the $(document).ready() func­tion? Too com­pli­cated. It wouldn’t get done…).

This is fun. Now, what about ads?