If cross-domain link tracking is switched on, links to domains in the relevant array should have a long string of parameters attached to them. This requires GA to override the default behaviour of the browser and stop it from sending the user directly to the URL in the link. This fails with the GA module, however, because, although the correct _link method is passed into gaq at line 49 of googleanalytics.js, it does not then return false.

Adding "return false;" at line 50 fixes this.

Files: 
CommentFileSizeAuthor
#9 1608310+Cross-domain+link+tracking+fails+because+it+does+not+return+false.patch743 byteshass
PASSED: [[SimpleTest]]: [MySQL] 179 pass(es).
[ View ]
#7 1608310+Cross-domain+link+tracking+fails+because+it+does+not+return+false.patch742 byteshass
PASSED: [[SimpleTest]]: [MySQL] 179 pass(es).
[ View ]

Comments

Status:Active» Closed (cannot reproduce)

Sorry, I'm not sure how closing this helps. It's in Google's own documentation that in order for cross-domain tracking to work you need to return false.

https://developers.google.com/analytics/devguides/collection/gajs/method...

Otherwise _link() or _getLinkerURL() will not override the browser's default behaviour when you click a link, which is to follow that link. To tell if it's working or not, simply turn it on and see whether a link that it should work on has a query-string appended to it, something like:

?__utma=1.887369289.1337963650.1338020967.1338550310.3&__utmb=1.1.10.1338550310&__utmc=1&__utmx=-&__utmz=1.1337963650.1.1.utmcsr=xyz.org|utmccn=(referral)|utmcmd=referral|utmcct=/corporate/privacy-copyright&__utmv=-&__utmk=13927991

If it doesn't, it ain't tracking, and it certainly isn't for me, nor can I see how it possibly could without return false. Adding it fixes it.

Thanks, Jeremy

It's noted in foc that _link delays itself by a fraction of a second. Returning false cause many side effects.

Hmm, but without it cross-domain tracking doesn't work, which is also pointless.
"Return false;" is only needed within that "if" test, but does it prevent other things that need to be triggered by that click? If so then there is still a bug because it needs to prevent the click from causing the browser to follow the link: it has to override it with the link-tracking URL or it's not working.

Status:Closed (cannot reproduce)» Needs work

Sorry for reopening this, Hass, but I can't consider it closed. I don't know what you did to try to reproduce the bug but if your own test sites are not set up for cross-domain tracking you can always take a look at mine. If you go to http://www.iwm.org.uk/ and debug the javascript (a little awkward because the JS is aggregated), put a breakpoint at the following line in your code:

_gaq.push(["_link", this.href]);

Then click the link to "Shop" in the top navigation. You'll see it break on that line but when the link is followed it does not have the query string that is required for cross-domain tracking. If you know of examples where this works I'd be interested to see them. This is fixed by by suggestion, which should have no implications for anything else because it is inside the final "if" statement before a user leaves the website

jQuery command for return false is preventDefault(); as I know. http://api.jquery.com/event.preventDefault/

Status:Needs work» Needs review
StatusFileSize
new742 bytes
PASSED: [[SimpleTest]]: [MySQL] 179 pass(es).
[ View ]

Could you guys give this patch a try, please?

Version:7.x-1.2» 7.x-1.x-dev

StatusFileSize
new743 bytes
PASSED: [[SimpleTest]]: [MySQL] 179 pass(es).
[ View ]

It need to be event. or it has no effect. New patch.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.