I've just had a look at the code, as I'm trying to get google analytics event tracking working:
First, I just figured out what it's doing. _gaq starts off as an array, you push things to it. Then it loads http://www.google-analytics.com/ga.js which runs. This looks in the page for the array _gaq, processes the things in the queue, then removes it and sets up an object called _gaq in its place. This object has a method called "push" so you can still call _gaq.push() later on in your page. Clever stuff. So why's it not working for me? None of my events are showing up. I'm doing this:
window._gaq && _gaq.push(['_trackEvent', cat, name, val]);
and my events are not being tracked... window._gaq must be present in order for _gaq.push to ever work right? So what's going on? Just checking that cat, name, and val are all of a legitimate type.
Hard to test this stuff as I think you can only make changes today, then see if it worked tomorrow. Frustrating.
Paul Clarke's blog - I work + live in Hythe. Wed to Clare and dad to two, I am a full stack web developr, and I do mostly js / nodejs, some ruby, python, php etc. I like pubs, parkrun, eating, home automation + other diy jiggery-pokery, history, tree stuff, Television, squirrels, pirates, lego, + TIME TRAVEL.