How to add the script to your Discourse community
You can add Plausible Analytics tracking code to your Discourse community by adding a "Theme" component. You need to use our special hash-based script on Discourse forums.
Go to Admin > Customize > Themes in your Discourse admin to create a new "Theme" component.
Paste your Plausible Analytics hash-based script tag into the
<head>
section.Here's what the full script tag will look like (make sure to replace your-domain with the domain you've added to Plausible Analytics):
<script defer data-domain="yourdomain.com" src="https://plausible.io/js/script.hash.js"></script>
If you're using a proxy for your Plausible account, you can add the
.hash.js
as follows:https://yourproxylocation.com/js/index.hash.js
After adding your code, click on the "Save" button.
Now you can go to your Discourse community and verify whether Plausible Analytics script has been added and to your Plausible Analytics account to see whether the stats are being tracked. See here how to verify the integration.
Thanks to Justin DiRose from the Discourse team for contributing these instructions!