Abstracting Analytics
In re-thinking the way I approach the JavaScript on my site, I’m definitely leaning towards creating an analytics widget. I want to keep as much JavaScript as possible out of my HTML. So, in lieu of the code that currently sites at the bottom of any given page, I think I should do something 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 probably exist in a namespace like OOR.widget.Analytics.Modules.Google. If, for some reason, I decide to go back to Reinvigorate (which provides great data, by the way), I’d just add a new analytics module called OOR.widget.Analytics.Modules.Reinvigorate into the mix and modify my call with the appropriate parameters (but where would I make that change? Would I do it manually in my JavaScript file? Would I throw it in the head tag? Would I put all of that into a WordPress plugin so I could handle the changes in the admin? And if I do create a plugin for that, how then would I manage all of the other JS that should be handled once the DOM is ready to be manipulated? Widgetize the calls that need to go into the $(document).ready() function? Too complicated. It wouldn’t get done…).
This is fun. Now, what about ads?