Skip to content

Commit 6196a92

Browse files
Merge pull request #569 from i13-ctflora/patch-1
Update discourse-integration.md
2 parents 6e6af84 + 26f8343 commit 6196a92

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

docs/discourse-integration.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,29 @@ title: How to add the script to your Discourse community
44

55
import useBaseUrl from '@docusaurus/useBaseUrl';
66

7-
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](hash-based-routing.md) on Discourse forums.
7+
You can add Plausible Analytics tracking code to your Discourse community by adding a component. Since Discourse uses hash-based routing for the post threads, you should to use [our special hash-based script](hash-based-routing.md) on Discourse forums. You may also want to add some of the other options like file-downloads.
88

9-
* Go to Admin > Customize > Themes in your Discourse admin to create a new "**Theme**" component.
9+
* Go to Admin > Customize > Appearance > Components in your Discourse admin to create a new component.
1010

11-
* Paste your Plausible Analytics hash-based script tag into the `<head>` section.
11+
* Click 'Install' and then 'Create New +'. Give it a friendly name like 'Plausible Analytics', make sure the Type shows 'Component', and click 'Create'.
1212

13-
* 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):
13+
* For the 'Include Component...' section, click the 'Add All Themes' button to ensure that this tracker is enabled across all themes. However, you may have themes that you don't want to track (maybe a special theme for Admins) in which case you can use the drop-down to select the specfic themes where you want the Plausible script added.
14+
15+
* Then click on the 'Edit CSS/HTML' button. Make sure you're in the 'Common' section (not 'Desktop' or 'Mobile'). Go to the `<head>` section (not the 'header' but the 'head') and paste in your Plausible Analytics script tag.
16+
17+
* Here's how the full script tag should look inside the `head` section:
1418

1519
```html
1620
<script defer data-domain="yourdomain.com" src="https://plausible.io/js/script.hash.js"></script>
1721
```
1822

19-
* If you're using [a proxy](/proxy/introduction.md) for your Plausible account, you can add the `.hash.js` as follows: `https://yourproxylocation.com/js/index.hash.js`.
20-
21-
* After adding your code, click on the "**Save**" button.
23+
* Note: Replace "yourdomain.com" with the site you're tracking in Plausible. If your Discourse is on a sub-domain of your main site, you could track them together by entering your main site here. Alternately, you could create a separate site in Plausible for yout Discourse to keep them separate. See [here](https://plausible.io/docs/subdomain-hostname-filter) for a deeper discussion.
2224

23-
Discourse has cross-site protections by default, and to allow Plausible to collect data, you need to add the Plausible URL to the setting called **content security policy script src**
25+
* Note: If you're using [a proxy](/proxy/introduction.md) for your Plausible account, you can add the `.hash.js` as follows: `https://yourproxylocation.com/js/index.hash.js`.
2426

25-
* Go to Admin > Settings > search for: *content security policy script src*
27+
* After adding your code, click on the "**Save**" button at the bottom, and the "**<**" button in the top left to get back to the component screen. If it saved properly, you should see the `head` section called out as a 'custom section' under the CSS/HTML header.
2628

27-
* Add `plausible.io` or your custom URL (i.e., `yourproxylocation.com`) as an item and click the green checkmark.
29+
Discourse will automatically add a nonce to the script to satisfy the Content Security Policy headers, so no further action is necessary for that.
2830

2931
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](troubleshoot-integration.md).
3032

0 commit comments

Comments
 (0)