Piwik with image galleries

Hi,
I have a Fancybox image gallery on my website.

At the moment piwik only registers the “download” of the first image that is clicked and not of any others that are then clicked after the popup appears and the next button is clicked.

Is there any way that piwik can detect every image that is viewed in my gallery?

Thanks

Yes it should be possible, please take a look at the Javascript tracking user guide: JavaScript Tracking Client: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

Thanks,
I have kind of got it working I have the JS thumbnail script triggering a manual event giving me an image number, I would of prefered to have this as a download and not an event but I don’t know much js I also cannot get the next and previous buttons working as I cannot figure out how they call the image so I have disabled them.

This is working for me but if anybody can help me with the JS of fancybox I would appreciate it.