Skip to main content
Support home / Integrations

Discourse

Adding the Fathom script to your Discourse Site

This guide walks you through adding your Fathom script to your Discourse site so you can start seeing privacy-first analytics for your community.

Step 1: Get your Fathom Script

  1. Log in to your Fathom account
  2. Go to SettingsSites, then choose your site or create one if you haven't already
  3. Click on the Install tab, then copy the script

It’ll look something like this:

Note: If you're copying the below example script (or any of the other example scripts on this page), make sure to replace the dummy Site ID with your own Site ID. It can be found in your site settings.

<script src="https://cdn.usefathom.com/script.js" data-site="YOUR-SITE-ID" defer></script>

Step 2: Ignore canonicals

Because Discourse comes with a canonical link to your homepage, baked into the default/core setup, you’ve got to tell your Fathom script to ignore canonicals by adding data-canonical="false" to your script.

Here's an example script with that added:

<script src="https://cdn.usefathom.com/script.js" data-site="YOUR-SITE-ID" data-canonical="false" defer></script>

This will then show unique URLs within your Discourse site, not just your homepage.

Step 3: Enable SPA tracking

Discourse is a single-page app (SPA), which means it dynamically loads new content without reloading the page. To handle that, you have to enable SPA mode via your Fathom script by adding data-spa="auto", like so:

<script src="https://cdn.usefathom.com/script.js" data-site="YOUR-SITE-ID" data-canonical="false" data-spa="auto" defer></script>

Step 4: Add the Fathom Script to your Discourse theme

You’ll be embedding the Fathom script into your site’s

by editing your Discourse theme. Here’s the easiest and cleanest method:

  1. Go to your Discourse Admin Panel
  2. Navigate to CustomizeThemes
  3. Choose the theme you’re using
  4. Click Edit CSS/HTML
  5. Switch to the <head> tab
  6. Paste your Fathom script at the bottom
  7. Click Save

Step 5: Test your setup

  1. Open your Discourse forum in another window
  2. Visit your Fathom dashboard
  3. You should start seeing real-time page views

Note: If you're not seeing any data appear in your dashboard, ensure that you have any ad-blockers or VPN's you're using temporarily disabled, as they may be blocking the Fathom script.

Further customization

To learn about all the options we offer, read our advanced documentation here.


If you still have questions or require help with anything, please reach out to us and we'll happily get things sorted out for you.


Can't find what you're looking for?