Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

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

Solved by Anna View solution

Started by Anna 3 years ago · 2 replies · 769 views
3 years ago

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!

3 years ago

@Netzhexe,

  • 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:

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

Found it after a little bit of Googling.

last edited 09/11/23 by pamtbaau
3 years ago Solution

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

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 64 18 hours ago
Support · by Anna, 3 days ago
2 68 20 hours ago
Support · by Justin Young, 21 hours ago
1 35 21 hours ago
Support · by Duc , 1 week ago
2 71 6 days ago
Support · by Colin Hume, 1 week ago
2 63 6 days ago