How to create event tracking tool same as its google

How to create the event tracking tool for clients like google.

_gaq.push(['_trackEvent', 'Downloads', 'PDF', '/salesForms/orderForm1.pdf']);

Even though you don't accept answers, I will still give you a pointer.

Add listeners for all the events that you want to track in the body tag. Since there is event bubbling, all the events triggered anywhere in the page (if event.stopPropogation() is not used), will be picked up. Then it is upto you to do whatever you want to do.