Logging / Statistics for AJAX Requests?

I’ve been working on a gallery in Rails. I’m using AJAX requests to
show/hide/move my images. Each image is contained in its own div with
information and a link to lightbox to pop up a larger version.

Everything works in that regard, however - I would like to add the
ability to log when a user clicks to view the larger ‘lightboxed’
versions of the images. I figured something like that wouldn’t be too
hard to implement, and that perception has caused me to spend the better
part of the day trying to fix it.

Right now I’m using “link_to”. I thought I could have an action that
would receive the name of the requested image in the options hash, but
that doesn’t work. I was thinking that I could just view the
xml_http_request directly, but I haven’t found a way of doing that (as
the xml_http_request? just returns a bool).

I’ve looked all day for the answer to this, but I haven’t found
anything, any input would be much appreciated. Thank you for your time.