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
Log in to your Fathom account Go to Settings → Sites, then choose your site or create one if you haven’t already 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.
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 addingdata-canonical="false"
to your script.
Here’s an example script with that added:
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 addingdata-spa="auto"
, like so:
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:- Go to your Discourse Admin Panel
- Navigate to Customize → Themes
- Choose the theme you’re using
- Click Edit CSS/HTML
- Switch to the
<head>
tab - Paste your Fathom script at the bottom
- Click Save
Step 5: Test your setup
- Open your Discourse forum in another window
- Visit your Fathom dashboard
- You should start seeing real-time page views