How to disable Fathom Analytics in development environment
December 29, 2022
Often you want to block yourself from being counted in your own page views while you develop your site.
One way to do this is to paste fathom.blockTrackingForMe()
in your JavaScript console. However, you’ll have to remember to do this for each browser you develop in, and the setting will be removed if you clear your local storage.
Instead, you can use the data-included-domains
setting that the Fathom tracking script provides.
If your website is under example.com
and www.example.com
, you can modify your Fathom script to look like this:
<script
src="https://cdn.usefathom.com/script.js"
data-site="YOUR_SITE_ID"
data-included-domains="example.com,www.example.com"
defer
></script>
Note that you have to add both the “root” domain and the www subdomain if your site uses both.
Now, the script will only track page views on your production domains, and not in your local development environment.
Subscribe to my newsletter!
A weekly round-up of new blog posts and updates to projects I’m working on.