To add support for Plausible Analytics to your Discourse instance
First, add your domain to your Plausible Analytics instance and grab your tracking code. It should look something like this:
<script async defer data-domain="community.example.com" src="https://plausible.example.com/js/plausible.js"></script>
Next, you do need to make a modification for this to work with Discourse’s single-page Ember app.
- Change
plausible.js
toplausible.hash.js
.
The final result should look like this:
<script async defer data-domain="community.example.com" src="https://plausible.example.com/js/plausible.hash.js"></script>
Finally, create a new theme component from Admin > Customize > Themes. Then paste the modified tracking code in the </head>
section. Click Save.
Make sure to add this to all available themes so you can track analytics across all users!
That’s it!