You want the Google Analytics Event Tracking API .
This allows you to embed events in the JavaScript code of your web page registered in Google Analytics. Something like that:
<a href="#" onClick="_gaq.push(['_trackEvent', 'Images', 'View', 'Specific Image Name']);">Play</a>
or more realistic, something like this:
function openLightbox(id) {
A little of Spelunking Firebug shows that the Fancybox right and right arrows are anchor tags, for example:
<a id="fancybox-right"> <span id="fancybox-right-ico" class="fancy-ico"></span> </a>
So you can hook the click event like this:
$("#fancybox-right").click(function(){ alert("hi"); });
jQuery adds this click handler to the collection of click handlers that will fire when a button is clicked. Therefore, the original behavior of the button will be saved.
In this case, it would be more useful to go up to the "# fancybox-inner" sibling and get the image URL.
$("#fancybox-right").click(function() { alert( $("#fancybox-inner > img").attr("src") ); });
Or, to get into the Google Analytics event API
$("#fancybox-right").click(function() { var image_url = $("#fancybox-inner > img").attr("src"); _gaq.push(['_trackEvent', 'Images', 'Click Right', image_url]); }); $("#fancybox-left").click(function() { var image_url = $("#fancybox-inner > img").attr("src"); _gaq.push(['_trackEvent', 'Images', 'Click Left', image_url]); });