I am using Statistics (default module) on my site and would like to increment the node counter if I view an image in Lightbox.
In my case I have a list of image thumbs. When I click an image to open it in Lightbox, I want to log the hit for this picture.

By doing so, I can create a view with the most popular images.

I know it's doable to track Flash clicks etc using Javascript for Google Analytics.

Comments

jjjames’s picture

Yes, this would be great. For some reason the url of the iframe within a lightbox is http://mysite.com/node/8/lightbox2 I think that's why the stats don't get logged, it's not the actual node page?

Also, lightbox with comments would be cool...but i guess that's what the iframe would be for.

yurg’s picture

+1 for this feature. Using Views we can see "image-in-node" popularity, but "image-in-lightbox" views counter would be very valuable for Views+Imagefield+Imagecache+Lightbox - based galleries.

davemybes’s picture

I have implemented this for videos by modifying the lightbox_video.js and inserting a $.get() function just before the Lightvideo.createEmbed() function call. However, I haven't done this for images, so I don't know where a similar function would go. Maybe somewhere just after line 255 (start: function...). Anyway, you need to then create a menu callback in a custom module for the get call, and run a custom function that inserts counts into a custom table, or updates the node_counter table itself (check statistics_exit for the db_queries to run).

Ideally, an option somewhere to enable this without hacking the module would be ideal, or a way to hook into the javascript maybe?