Matomo Analytics

Is there any other (more direct) way of integrating Matomo with Discourse, instead of using the plugin?

How’s the cron of root — there should be something like this:

*/12 * * * * /var/www/matomo/console core:archive --url=https://<home-of-matomo>/ > /var/log/apache2/matomo-archieve

(Of course time and logging are personal preferences, and path can and will be different)

But the sad story is this start to be out of scope of Discourse — your forum if sending data and Matomo gets it, is just doesn’t show it to you.

I’m not sure where the cron settings are, in this instance.
Also, as i already have other websites being properly tracked, i would assume that Matomo’s general config is alright.

Yeah, will head over to Matomo’s forum as well.
Thanks for your inputs!

If it can track everything else then the issue is not cron. Or Matomo per se.

What happends if you stop using CSP, letting it only log?

If i disable CSP, i’m getting the same results.

Same logs, no error, no data.

Any idea about this?

No idea, but you can give a try — put the code snippet on header and give a try.

Otherwise I have only one trick left: take a (coffee)break and double and triple check your settings in the component. It is so easy to not see obvious error, like wrong ID or misspelled host.

This should REALLY be added to the main instructions as it seems like a requirement UNLESS one were running Matomo on the same server as Discourse which I would think would be very rare.

Also in my case my Matomo is on another server maintained by another group and I’ve got a URL for it like https://subdomain.domain.com/subfolder/piwik.js and in this case it’s not super clear to me what domain pattern I should use in content_security_policy_script_src so I for the moment am just listing out multiple domains in that setting line by line which I don’t feel great about like:

https://subdomain.domain.com
https://subdomain.domain.com/
https://subdomain.domain.com/subfolder
https://subdomain.domain.com/subfolder/
https://subdomain.domain.com/subfolder/piwik.js
https://subdomain.domain.com/subfolder/piwik.php

…and then it lets you specify an order with an Arrow option for sorting up and down… which is all great - who doesn’t like options… but in this case when trying to configure something to work probably clear concise direction is most valuable.

The only thing I AM confident of is I did indeed include https:// before my URL which I’m sure is good as the cert is good, so is the connection, you said it in your post and content_security_policy_script_src instructions denote it under it’s field as well…

Is anyone super confident to tell me what domain pattern I should really use based on the context I provided above? Thanks in advance.

When I try to add my Matomo host URL (https://analytics.cosmos.coop) to the content_security_policy_script_src field, I receive the following error:

content_security_policy_script_src: Value must be either ‘unsafe-eval’ or ‘wasm-unsafe-eval’, or in the form ‘-’ where supported hash algorithms are sha256, sha384 or sha512. Ensure that your input is wrapped in single quotation marks.

Any idea what could be wrong here?

1 Like

Did you wrap the URL in '?

Discourse now uses a “Strict Dynamic” CSP, so adding individual URLs is no longer necessary (or possible). More info here:

I’ll remove that section from the OP here. Thanks for the heads-up @madrush

4 Likes

Thank you! I’ve got it working now.

This theme component is working great. Thanks to the contributors!

Is anybody using Goals or other advanced features of Matomo?

Ideas for improvement:

  • User groups (including custom groups) could be tracked through Matomo Custom Variables.

  • Allow to send custom Events from Discourse to Matomo. That would be useful for connecting to Goals.