Thanks UncleCheese! I ended up having some help from the SilverStripe IRC and I thought I would share the results here, for the non jQuery techies like me. It is actually quite simple, now that I know how to do it.
1. download the latest jQuery library from here: http://jquery.com/ on the big download button (it's just one file)!
2. upload that file to mysite/javascript
3. go to mysite/code and select your template (eg. page.php) and add it as a requirement like this: Requirements::javascript("mysite/javascript/jquery.yourlibrary.js");
5. Create the query such as:
$(document).ready(function() {
alert('This is being called on load');
$('a.gafollow').click(function() {
alert('This is being called on click, with href set to '+this.href);
pageTracker._link(this.href);
});
});
and save it in a file and call it jquery.onload.js in mysite/javascript
6. go to mysite/code and select your template (eg. page.php) and add it as a requirement like this: Requirements::javascript("mysite/javascript/jquery.onload.js");
7. add the gafollow class to all the outbound links you want the link function to apply to
8. Test to see if you see both alerts
9. Delete both alerts and you are done.
Hope that helps someone!