How to record when user follows external links without slowing user down

Posted by taw on Stack Overflow See other posts from Stack Overflow or by taw
Published on 2010-05-23T07:25:35Z Indexed on 2010/05/23 7:30 UTC
Read the original article Hit count: 203

Filed under:
|

I want to track when user clicks external links for analytics purposes. The simplest solution is to replace all external links with links to special record-and-redirect controller, but that would slow the user unnecessarily.

The second idea would be to override click event and within in $.post a message to record controller, then let the main event handler happen, which will usually be either click (open link in same tab) or middle click (open in new tab) - good either way, and the user won't have to wait for wait for my server to record it, it's fire-and-forget. (I don't care if users without Javascript don't get tracked)

Is that a reasonable way to go? Or what else would be the best way to track all external link clicks?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX