<input type="submit" onClick="_gaq.push(['_trackEvent','Subscribe','By Email','Subdomain 1']);" value="Subscribe" />
I then set about testing the forms to make sure they were tracking. Despite submitting each form at least once only 2 events were tracked. I knew that the clicks had occurred as not only was I given on screen confirmation but I received emails to let me know I had subscribed.This is what GA was telling me for all events across all subdomains:
Despite GA knowing that 42 visits sent events only 21 were actually tracking. Strange.
Then I discovered this interesting article by Joze Uzcategui of Cardinal Path, who did an experiment to determine whether onMouseDown records a different number of events to onClick. Turns out it does.
OnMouseDown records the click as soon as the visitor starts pressing the mouse button, whereas onClick occurs after the button has then been released again. The theory is that today's super-fast browsers allow the page to unload before the onClick event has been registered. (This may be confirmed by the fact that Jose's stats showed a greater discrepancy for Chrome, Safari and Firefox than for IE.)
Jose's results were staggering. Of 235 visits, 205 onMouseDown events were recorded whereas onClick tracked a mere 122. For IE there were 5% more onMouseDown than onClick events tracked. For Firefox, this increased to 36% and for Chrome it was an astounding 84%.
This raises some interesting questions, not least where should I be recommending clients place their tracking code. Clearly it doesn't make sense to place tracking code in both events, unless you are somehow going to distinguish between them, as Jose did in his experiment. But as another reader pointed out, it may be a common and valid action for a visitor to begin to click, then change their mind and move the mouse to another part of the screen before releasing the button. I know I do this. OnMouseDown would register this as an event, when it clearly isn't. However,one could argue that having a few extra events recorded is a small price to pay to prevent so many potentially real events being ignored. Sure, GA has told me that 42 visits sent events but if I know nothing about half of these events, not even which sub-domain they came from, then what use is that to me?
Possible solutions are to:
- Track both onMouseDown and onClick, making sure to use your labels or categories to differentiate between the two. You would still need to figure out how to use the resulting data though, perhaps taking an average to account for any mouse depress-drags.
- Add a time delay to all events, similar to the recommended solution for outbound links.This would be imperceptible to the visitor but should delay the event for long enough for GA to track it before the page unloads.
- Use onMouseDown instead of onClick and accept that there may be some false events recorded. Perhaps perform some user tests to determine the percentage of actions that can be assumed to be depress-drags.
I ran a quick test using IE and in the time it has taken me to write this post the event was showing in GA - this is a record for all the testing I've done across these sites so far. Just to confirm, gobsmacked as I was, I repeated the test on a further 3 sub-domains that had previously failed to track. Sure enough, those events also appeared in GA in record time. So, to be sure I tried the first one again in Chrome. Of course, just to make this a totally moot point that event turned up quick-smart too. I've since submitted 3 more forms from Chrome and 1 from IE; 2 of the Chrome forms haven't yet tracked. Clearly I have a lot more testing to do.