Only the click on the first thumbnail is being tracked but I would like to track all impressions of images within the fancybox gallery. I tried it with visible elements but somehow it doens’t record anything.
Could anyone point me in the right direction. I suppose it’s the same for all kinds of lightbox galleries.
Check out the API section of the fancybox docs.
It tells you that you can listen to the event that an image is being viewed with
$("[data-fancybox]").fancybox({
afterShow: function( instance, slide ) {
console.log("slide is being viewed")
}
});
So all you need to do to track an event in Matomo is to replace the console.log with something similar to _paq.push(['trackEvent', 'Documentary', 'Play', 'Thrive']);. If you try around a bit, you should be able to extract the open image title or filename (maybe look into slide.opts).
Hi Lukas,
is there any chance that you have another tip how to implement a “trackEvent” within the “afterShow”-Part? I tried for hours and still haven’t figured out how to use this
Unfortunately, the tip from Ronan doesn’t work for me, due to not changing URLs in the adress-line