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.


  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.

  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?


  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

    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 ???

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


  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.


  6. Well google analytic has really different now days.

  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 center dashboards

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

  9. Nice answers in replace of the question with real point of view and explaining about that.
    Wikipedia’s traffic

  10. Poker online baru kembali lagi 9 dekade, ke tahun 1998 setelah judul game pertama kali tiba di web. Namun demikian, tengara yang sebenarnya karena sejarah poker yang sebenarnya adalah tahun 2002. Per tahun kalender
    paito warna oregon 03
    paito warna oregon 12

  11. If you really desire to get such type of information, visit this blog quickly.
    web design deliverables

  12. Two full endorsement for this magnificent article of yours. I've genuinely refreshing scrutinizing this article today and I figure this might be uncommon contrasted with other articles that I've examined now. On the off chance that it's not all that much difficulty prop this work up on in a comparable quality.

  13. This is a great post; it was very edifying. I look ahead in reading more of your work.
    UX design agency

  14. I read your blogs regularly. Your humoristic way is amusing, continue the good work!
    lead conversion system Daven Micheals

  15. The information you have posted is important. The objections you have insinuated was worthy. Thankful for sharing.
    digital marketing courses in malaysia

  16. Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post.
    digital marketing training institutes in hyderabad

  17. Incredibly conventional blog and articles. I am realy very happy to visit your blog. Directly I am found which I truly need. Thankful to you and keeping it together for your new post.
    data science courses in gurgaon

  18. They were praised for clearly understanding the client's needs and being sensitive to their development timeline.
    UI design agency

  19. great article!! sharing these type of articles is the nice one and i hope you will share an article on data science.By giving a institute like is one the best institute for doing certified courses
    data science training in aurangabad

  20. I got this site from my pal who shared with me about this website and at the moment this time I am visiting this site and reading very informative content at this time.check here

  21. The article posted was very informative and useful. You people are doing a great job. Keep going.
    data scientist course

  22. I agree. You have made the nice blogs with the great info in the contents.
    design firms

  23. Several e-commerce websites stock spare parts of car various models. However, you need to be careful in selecting the right one for your car. Remember not all spare parts will fit your car because each part is made for a specific car model and they are unique. So, while you buy Spare Parts For Tata Safari, or for another brand, make sure you consider the car model before going ahead of the purchase. Tata Spare Parts Catalog

  24. Thank you for sharing information. I love your blog! Reference:

  25. Looking for high-quality Tata Ace Spare Parts? Look no further than BP Auto Spares India. Find the best deals on Tata Ace spare parts and ensure your vehicle runs smoothly. Shop now for authentic Tata Ace spare parts at BP Auto Spares India. Auto Spare Parts

  26. Ultimately, your choice of solution will depend on your specific goals and the importance of tracking accuracy in your data analysis. It is important to continually monitor and make necessary adjustments to ensure you are getting accurate and useful information from your Google Analytics implementation.