How to record when user follows external links without slowing user down
- by taw
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?