You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/discourse-integration.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,25 +6,25 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
6
6
7
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.
8
8
9
+
## Step 1: Get your Plausible snippet
10
+
11
+
We display your snippet during the process of adding a new site to your account. You can also see the snippet within the "**Site Installation**" area of the "**General** section in your [site settings](website-settings.md).
12
+
13
+
## Step 2: Install snippet in Discourse
14
+
9
15
* Go to Admin > Customize > Appearance > Components in your Discourse admin to create a new component.
10
16
11
17
* Click 'Install' and then 'Create New +'. Give it a friendly name like 'Plausible Analytics', make sure the Type shows 'Component', and click 'Create'.
12
18
13
19
* 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 specific themes where you want the Plausible script added.
14
20
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:
* 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 from step 1.
22
22
23
-
*Note: Replace "yourdomain.com" with the site you're tracking in Plausible. If your Discourse is on a subdomain 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 your Discourse to keep them separate. See [here](https://plausible.io/docs/subdomain-hostname-filter) for more information.
23
+
*In the snippet, update `plausible.init()` to `plausible.init({ hashBasedRouting: true })`. This allows plausible to track hashed page paths that Discourse uses during navigation.
24
24
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`.
25
+
* Note: If you're using a proxy, see [relevant instructions](/proxy/introduction.md).
26
26
27
-
* After adding your code, click on the "**Save**" button at the bottom and go 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.
27
+
* After adding your code, click on the "**Save**" button at the bottom and go 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.
28
28
29
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.
0 commit comments