I am trying to add google analytics to a web application built in asp.net c# that is already pretty mature. The requirement is to have all sorts of event tracking on buttons clicks, breaking up page views into different sections, based on which view gets displayed, etc. I am wondering if there is a way to build a framework that does this, because the asp.net web application is already working, with many button events, and onlick events already present. I didn't want to have to wire up each and every button with specific trackers, etc.... I know I have to do some of it, but if I can make a framework that can be used everywhere, then thats what I want to do - unless there is a framework already present that integrates this.
For the button clicks and other actions generated by user interaction you probably want to look at a convention-based approach. You would first apply appropriate CSS classes -- and perhaps other metadata -- to the buttons. Then add a script that looks for your CSS classes and wires them to fire off analytics events before returning true and letting processing continue. This is relatively painless to implement while also being easy to extend.
I'm not quite following the bit about "which view gets displayed", you might want to elaborate a bit there.