Time doesn't have to be an issue - when I write something like this, the script that is called to count does the redirect as the first thing, then closes STDOUT. At that point, the user is already redirected, and your script can take all the time it needs to analyse and record the click.