How to log all outgoing links generated in a view? What is the most lightweight method of tracking all outgoing links generated in a view. By lightweight I mean that I don't want to have to load a module such as statistics that will potentially slow down my site due to it going above and beyond my needs.

Basically I would need to record the data into a database using the following structure:

product_id | uid | timestamp


The product id is associated with each link and is a separate field. The purpose would be to create sets of clicked links for each user, product, etc. This could in turn be used as a dataset for subsequent user/item analysis. I would imagine I would need to use some sort of callback function.

Can anyone provide an example or any hints?
You could use jQuery to attach a click event to each link that triggers an ajax request to record the click.

The problem with this is that the page may redirect before the ajax request has had a chance to fire so you will have to prevent the default action of the click, and then perform an ajax request with async=false, and then provide a call back function to redirect to the links destination.

Not exactly lightweight...

Another option is to define an outbound link function in PHP that will accept the final destination as a argument. So the link would look like /outbound?dest=http%3A%2F%2Fwww.google.com.

Then in that function you can record the click, and then redirect them on to the destination passed in...