Monday, August 6, 2012

Google Analytics: onMouseDown tracks more events than onClick

Recently I added some Google Analytics event tracking code to some very simple web forms across a number of sub-domains. The forms took just one field, an email address, and I placed the tracking code in the onClick event, as suggested by Google in their online documentation:
<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.

9 comments:

  1. Lindsay,
    I have been struggling with this for a while with several clients for event tracking in Safari and Chrome. Thanks for the suggestions. We haven't had luck with the click delay as Google recommends, but we'll try testing a mouse down event. This has clearly become a much bigger issue over the past 12 months with the growth in popularity of these browsers.

    ReplyDelete
    Replies
    1. Nếu bạn đang muốn đăng tin bán nhà hay bán đất hoặc bạn muốn mua nhà hay đất thì hãy đến với chúng tôi rao vat mien phi, với chất lương hàng đầu chúng tôi sẽ giúp các bạn , đăng tin và xem các khu vực nha dat quan go vap, ban dat quan 9, nha dat quan thu duc , nha dat quan binh tan , nha dat quan tan phu , nha dat quan tan binh và các khu vực khác trên toàn quốc với uy tín và hiệu quả cao khi bạn đến với chúng tôi.

      Delete
  2. Hi Elizabeth,

    Thanks for your comment. I'd be really interested to hear how you get on with using onMouseDown as I'm wondering whether this is the way to go. Please would you post back when you have tried it and have a bit more information?

    Cheers,
    Lindsey

    ReplyDelete
  3. Hi Lindsay,

    I think you've just solved a massive problem for me. I have a few affiliate sites that have gradually shown a deteriorating click-thru rate over the last year or so.

    I've alway wondered why IE users performed just fine while other browsers showed similar diferentials to the ones you found. I'd resigned myself to making trial and error changes to my pages (an awful lot of fruitless work) to try and nail down why other browsers performed so badly.

    Well recently I've seen a huge increase in Safari visitors who have traditionally been the absolute worst performers and it struck me that even if they hated what they saw on my page at least a few out of all those people would accidentally or curiously click something. So ! it suddenly seemed glaringly obvious that something was up with the event tracking for that particular browser.

    As a quick test I loaded windows safari and clicked a few links and waited for them to show in Google Analytics as "external" events. They did not show. So I figured this must be a hot topic among some people but after hours of searching have found very little except a reference to a bit of Google advice to put a time delay on the onclick for certain situations - it was beyond me so I moved on and finally found your post.

    I did a global change to all my onclicks to switch them to onMouseOver and after them testing just fine in safari I've now posted them on the net. I agree with you - I'd much sooner have to allow the odd "nearly click" than have no idea whats going on. I think its likely that my only reliable click thru stat has been IE for the last year or two. I am therefore now thinking that my declining click-thru performance probably matches the increase of visitors using other browsers especially safari.

    Of course there could be other issues but at least now I can stop chasing wild geese and find them.

    Thanks for being so clever and sharing this. If I find any problems I'll be sure to come back and let you know but aside from the "nearly click" issue which I would expect to be insignificant in my traffic I can't think of any potential trouble in using onMouseOver.

    very many cheers
    Phil

    PS - I always did see the odd safari click event now and then so it never occurred to me to check the tracking until the recent high numbers mad things more obvious. I wonder if the general increase in broadband has increased the chances of an onclick for an external link from being registered ???





    ReplyDelete
  4. oops - glaring error in my comment above. I did in fact use onMouseDown and not onMouseOver :s

    Phil

    ReplyDelete
  5. Hi Phil,

    Thanks for your comment. It's really interesting to see that you have actually seen this in practice and I appreciate you taking the time to tell me about it. I think a move to onMouseDown might be the way forward for me too. I'll be interested to hear if you do have any issues - but hopefully not. It would be nice to have a satisfactory solution.

    Cheers,
    Lindsey.

    ReplyDelete
  6. Well google analytic has really different now days.

    ReplyDelete
  7. It's important that you keep your overall business and web site goals in mind in order to ensure that the analytics solution you choose actually addresses these goals.call center dashboards

    ReplyDelete
  8. I'd be trampled if all sites gave articles like these awesome articles.
    LinkedIn PowerConnector

    ReplyDelete