The googleanalytics.js catches all clicks on links, but does not prevent the default browser behavior, what will not delay the target url loading and may break successfully logging of clicks as recording may be interrupted while loading the tracking code. As documented in http://www.google.com/support/analytics/bin/answer.py?hl=en&answer=55527 the script should wait fraction of a second.

As per http://fuelyourcoding.com/jquery-events-stop-misusing-return-false/ the default browser behavior should be blocked with event.preventDefault().

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hass’s picture

Status: Active » Needs review
FileSize
1.95 KB

Patch attached.

hass’s picture

Tabbycat’s picture

Hi hass,

Thanks for looking at the issue. Taking a quick look at your patch I noticed that you've added "event.preventDefault();" in one path through the code where I think setTimeout isn't being done.. i.e.:

if (ga.trackDomainMode == 2 && isCrossDomain.test(this.href)) {
// Top-level cross domain clicked. document.location is handled by _link internally.
+ event.preventDefault();
_gaq.push(["_link", this.href]);
}

So my guess is that particular path through the code either should be calling setTimeout but isn't, or else by design it should allow the original event to still occur!

izmeez’s picture

subscribing

jsquyres’s picture

subscribing

hass’s picture

Status: Needs review » Closed (won't fix)
Issue tags: +bug, +Known Issues, +future

As we are not able to click a link programatically or at least I don't know how and many docs around the net say it is not possible - and I do not like to rebild a browser in javascript to be able to support custom javascript click cases - I keep it for now with the roled back patch. Maybe somedays we found a solution. Until than we may theoretically lose a very few hits as in past :-(