The discussion revolves around the Matomo Analytics theme component for Discourse, an official plugin that enables Matomo (formerly Piwik) analytics on Discourse forums. The component allows users to track website activity by installing it via a GitHub repository and configuring settings such as the host URL, website ID, and tracking options. Key features include support for GDPR compliance through options like doNotTrack and disableCookies, though some users noted these were initially missing. The thread includes troubleshooting tips, such as ensuring the Content-Security-Policy is updated to allow Matomo’s domain and checking browser developer tools for tracking requests. Users also discussed the need for an opt-out feature via an iframe, which is not natively supported in Discourse posts. The component was updated to address these concerns, and users confirmed it works after resolving configuration issues. Additionally, Matomo offers free hosted solutions for open-source projects, which may benefit Discourse communities seeking privacy-focused analytics.
In order to comply with the European laws, users must have the possibility to reject piwik’s cookie. Piwik offers a really simple solution for this, by including an IFrame.
Unfortunately, Discourse doesn’t allow iframe tags in posts…
Does anyone see a way to include this piwik iframe in Discourse TOS ?
Thanks.
So I have the JS loaded into the theme customizations, and the external “theme JavaScript file”* is linked in my test browser, just under where I inserted it like in the screenshot in a few posts earlier … BUT the requests aren’t coming through to the Matomo tracking web server.
(Tracking works fine for other non-Discourse sites, FWIW.)
Has anyone else seen that happen?
* e.g. https://discourse-cdn.example.com/standard11/theme-javascripts/{numeric_string}.js?__ws=my-discourse-forum.example.org
I’m confused why the tracking code is sending a custom variable called Anonymous. Isn’t that custom for your particular Matomo setup? It doesn’t seem like it should be there for everyone.
You have to whitelist your Matomo-URL inside the Content-Security-Policy-Header. Search for the admin setting content_security_policy_script_src and add your domain (with https:://) there
I’m having trouble making this work on my installation. I’ve installed the component, and added it to my theme, but Matomo is saying there’s no data for the site. I’d think I have the settings correct:
Edit: Further investigation reveals that the error in the Javascript console only appears in Firefox, not in Chrome (with the latest versions of each on a Mac). And I am now seeing some results in Matomo, though Firefox is conspicuously absent–all but one of the visitors are using Chrome; the one exception is using Safari.
suggests that it could be Firefox’s “do not track” settings, but even when I disable them for my site, I’m getting the same error in the web console with Firefox. And Firefox doesn’t seem to be viewing this as a tracker in any event: