Does Grav set click handlers? Matomo (ex-Piwik) does not track downloads on Grav site

Hello everybody,

I have a Grav site that uses Matomo tracking (PHP only, no cookies). Works fine so far, but the PDF downloads do not get tracked at all. According to the Matomo FAQ, the problem might be other click handlers being set on the links. Since I’m not doing that consciously anywhere, it would have to be a built-in Grav thing (or possibly a plugin of course).

I don’t how how to find out whether that might be the case. Does anybody know about that, or how I might find out?

Thank you so much already!


  • Have you tried disabling all plugins?
  • Have you tried a bare template that does not add any assets (except the ones for Matomo)?

And you might try copying the following into the console of the browser. It will list all events attached to all elements:

	[document, window].concat([...document.querySelectorAll('*')]).map(el => {
		let evs = getEventListeners(el);
		// evs = ( ? { click: } : []);
		return {
			el: el,
			types: Object.keys(evs).join(', '),
			listeners: evs
	}).filter(item => item.types)

Found it after a little bit of Googling.

Hey, so this took me a while to get around to again. I set up a test site now and tried your snippet (thanks!), unfortunately this gives me an error: Uncaught ReferenceError: getEventListeners is not defined.

However, while setting that up I realised I had another Grav site using Matomo, and found that downloads do get tracked there as they should. And digging just a little into the plugins, I had been using the piwik plugin for the other site instead of the Matomo plugin – so I changed that, and now the downloads get tracked. I’ll put it in the issue queue of the new plugin.

Hope this saves somebody else some time…

1 Like