Sign inFree trial
Support home / Script Settings

Exclude specific pages

Fathom Analytics collects data for every page our script is loads on by default. But, if there are instances where you’d like Fathom to exclude a page from showing up with data on your dashboard, you can exclude it.

Step 1: Disable automatic tracking in Fathom

The first step is to add data-auto="false" to your Fathom script tag. This stops Fathom from automatically tracking a page load. Your script should look something like this:

<script data-auto="false" src="" data-site="YOUR-SITE-CODE"></script>

Step 2: Add in the logic

Here is where we check the pathname. We'll do a few examples here to show you what you can do.

Example 1: Blocking a single page In this example, we want to block a page called /secret-page. Here's how we do it:

if (window.location.pathname !== '/secret-page') {

Example 2: Blocking multiple pages

We want to block the following pages from being tracked on our website:


Instead of doing lots of IF statements, we're going to use an array:

var blockedPages = [
if (blockedPages.indexOf(window.location.pathname) < 0) {

Example 3: Blocking directories or path patterns

We now want to block all pages that are in the following folders. In the list below, we've used * to represent wildcards. So if you see/admin/*, it means we want to block every single page in the admin directory/folder from showing up in your data within Fathom.


Before we get to the code, let's be hyper-clear about something. We are blocking the sub-pages and the directory itself. So in the following example, we're looking to block /admin/, /admin/page-1, /admin/page-2, etc. and then the same with /private/, /private/page-1 and /private/page-2.

In this example, we're using `startsWith()``, which isn't compatible with Internet Explorer. If you need to support Internet Explorer, you'll have to roll something different.

var blockedDirectories = [
blockedDirectories.forEach(function(directory) {
if (window.location.pathname.startsWith(directory)) {
window.blockFathomPageview = true;
if (typeof window.blockFathomPageview == 'undefined') {

By using startsWith() instead of indexOf(), we don't run into unexpected situations, like accidentally blocking /blog/private when attempting to block /private.

One final note is that the above code won't block /admin (without the trailing slash). If you want to block /admin too, you'd need to add that to your blockedDirectories array.


If you ever find that you're trying to block specific pages, but they're still being tracked, make sure you double-check the URL of the page. If you're trying to block, but your code has /another-page-to-block/, it won't work. Why? Because of the slashes.

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.