Use Google Analytics to keep track of images viewed

Touch Gallery now includes a very simple event triggered whenever an image is viewed.

The event is tg.imageViewed

it includes 4 parameters:

  1. total - the number of images in the gallery
  2. file - the relative path to the current image (if the image is resized that'll be the image from the cache)
  3. title - the file's title attribute value if set
  4. desc - the file's description attribute value if set
  5. index - the current image's index in the list of images

Using with Google Analytics is pretty simple. Let's say you want to trigger a GA event and reference the image's title when it happens. Just do:

$(document).on('tg.imageViewed', function(e) { ga('send', 'event', 'gallery', 'image viewed', e.title); }); 

Of course, this is just an example. You can use whatever values you want.