I'm working on implementing GATracking for a group of pages. I want to track both pageloads and clicks on specific buttons. My goal is to create code that is easily adaptable without the need for extensive rework. Some functions already have bindings, so using multiple bindings in jQuery is not ideal. Additionally, I prefer not to use inline function calls.
One approach I'm considering is creating an array based on IDs and fetching values when needed. Alternatively, I could explicitly call functions on buttons or divs with href attributes, triggering a separate function once the binding is complete.
I'm seeking a more universal solution that centralizes most of the coding in a single class for versatility across various applications. How should I proceed?
For example:
1)
<div id="submit" class="submitClass">
(onClick binding already exists and adding multiple bindings in jQuery is discouraged).
2)
<li><a href="/" onclick='GATracking(<param1>,<param2>);'>Home</a></li>
(repeating this pattern for different functions would be tedious and lack generality)
Thank you in advance