Advanced script settings
You can see our basic installation instructions here (this works great for most users).
CMS / Frontend Frameworks
We have instructions for the following tools in the "Install Site" area.
Changing when our script is loaded
By default, our script is deferred, meaning our script loads once your HTML has finished loading. That means our script doesn’t affect your site load time or speed in any way (fast sites == better search engine rankings).
You can also swap out
async or just load it without either, but we don’t advise this. Instead, this is how our code should be most commonly used:
Honoring Do Not Track (DNT)
By default we track every visitor to your website, regardless of them having DNT turned on or not. That’s because Fathom is privacy-focused analytics, so nothing personal or identifiable is ever “tracked”.
That said, if you would like to honor DNT then update your code to include
Disable automatic tracking
By default, we track a page view every time a visitor to your website loads a page with our script on it. If you don’t want that functionality, you can turn it off by using
If there’s a canonical URL in place, then by default we use it instead of the current URL. This is what most customers want, and it’s why it’s the default. If you want to use the current URL, even if there’s canonical (ignoring the canonical), then use
Excluded or included domains
By default, you can use our tracking code on any domain, it doesn’t matter if you use it on multiple sites or domains.
You can, however, exclude one or several domains, so our tracker will track things on every domain, except the ones excluded by adding
data-excluded-domains="example.com" and use a comma to separate multiple domains (no spaces in between the domains, just commas). This is useful to exclude stats being tracked on your local development environment (if you have one).
If you want to go in the opposite direction and only track stats on a specific domain, you can use
data-included-domains="example.com", using a comma to separate multiple domains (no spaces in between the domains, just commas). For example, if you have 2 development environments and a staging environment, you might want to track stats on your live site,
example.com, but not on
example.local and not on
NOTE: For both included and excluded domains your
www. has to match your site's usage of
www.. For example, if your site loads as
www.example.com and you have
data-included-domains=example.com it will not track any visits as they do not match.
Single page applications
Note: With this code, it will still track the initial load. See “Disable automatic tracking” above if you don’t want this.
If you want to explicitly say “We are using only HTML5 History API” or “We only use hash-based routing”, you can use one of the following snippets:
It’s unlikely that you’ll be using hash-based routing but some people do (we do in our dashboard).
Client Side API functions
There are functions that can be called once the Fathom script has been loaded.
The typical use case for using this would be for someone handling routing manually themselves. Perhaps they have their own SPA / AJAX page loading, or they want more control over the data they send to Fathom.
In addition to this, you can also go more complex and set your own parameters (when using this method, the canonical will not be used, as this becomes the source of truth):
You do not have to send both of these properties. If you send just the referrer, the URL will be established using the default method (canonical or current URL).
Track a Goal
You can track a goal that you have already set-up in the Fathom dashboard.
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.