Ticket #752 (closed New feature: fixed)
piwik.js: Tracking middle clicks automatically (they do not fire onclick event)
| Reported by: | matt | Owned by: | vipsoft |
|---|---|---|---|
| Priority: | major | Milestone: | Piwik 1.2 |
| Component: | Core | Keywords: | |
| Cc: | Sensitive: | no |
Description (last modified by matt) (diff)
There is a regression from the old piwik.js and the new one: middle clicks that open in a new tab in modern browsers, and that are more and more used, are not counted anymore: they do not fire mousedown events.
Here is Anthon's explanation:
Switching from mousedown to click is consistent with how GA, Yahoo, and MS handle the event. If the user releases the button off the element (to abort the operation), no click is generated. Thus, mousedown can result in false outlinks/downloads being reported. I don't recall if right mouse button clicks generated mousedowns on the element, but if it did, there's no way to determine what popup menu operation was selected (open in new window/tab, copy shortcut, save target, etc). If we switched to mouseup, we'd also need a mousedown, to check for the same target element underneath and for double clicks. Striving to capture all clicks is a laudable goal but there are a lot a conditions that make tracking mousedown/mouseup difficult or unreliable. It's already unreliable to a degree. click/mousedown/mouseup all bubble and are cancellable. There's no way for Piwik to set the order that its eventlistener is called (eg first or last). An earlier listener could stop propagating the event. A later listener could cancel the click event so the href isn't followed.
Could we use the event.button as explained on http://www.programmersheaven.com/mb/java-script/304443/304443/right-and-middle-click/?S=B20000 Maybe there is a way of "special handling" the middle click use case and count these clicks?
Change History
Note: See
TracTickets for help on using
tickets.
