If you're using Google Analytics, you can use click tracking:
I recently setup click tracking on lightbox open, close and various other modal window bits/pieces for a metered pay wall system.
For example, within the lightbox/modal window "open" method:
// Track this lightbox instance:
'_trackEvent', // Method.
'Paymeter Lightbox', // Group.
'Lightbox OPEN group ' + count_txt, // Append count to "action" text.
count_txt + ' OPEN event' // Prepend count to "label" text.
The advantage to using a common tool like analytics is that it's got a ton of powerful ways to analyze the data. Not sure the goal of your project, but I thought I would mention.