Fathom Analytics Fathom Analytics

Installing our tracking code

To install our tracking code, go to Settings > Sites > and click on the tracking ID for the site you want to get the tracking code for.

It’ll look like this:

<!-- Fathom - simple website analytics - https://usefathom.com -->
<script>
      (function(f, a, t, h, o, m){
      a[h]=a[h]||function(){
       (a[h].q=a[h].q||[]).push(arguments)
    };
    o=f.createElement('script'),
    m=f.getElementsByTagName('script')[0];
    o.async=1; o.src=t; o.id='fathom-script';
    m.parentNode.insertBefore(o,m)
    })(document, window, '//cdn.usefathom.com/tracker.js', 'fathom');
    fathom('set', 'siteId', 'SITEID-DO-NOT-USE-THIS');
    fathom('trackPageview');
</script>
<!-- / Fathom -->

Copy and paste this right before the </body> tag in your website or footer template (if you use a CMS like WordPress).

Wordpress

If you use Wordpress, can you optionally use this plugin and paste your site ID into the plugin settings.

Single Page Application (SPA)

Fathom can track page views in SPAs. We support hash-based navigation and pushState. Make sure you test your implementation by clicking through your app & watching your current visitors area to make sure it changes correctly.

Hash Based Navigation

To tell Fathom that you are using hash-based routing, you should follow the installation instructions above and add the following snippet above the </script> tag.

fathom('set', 'spa', 'hash');

pushState Navigation

To tell Fathom that you are using pushState based routing, you should follow the installation instructions above and add the following snippet above the </script> tag.

fathom('set', 'spa', 'pushstate');

And that's all you need to do. Fathom will monitor hashchange for changes and track the path. This works for hash based and pushstate navigation.

Other

If you use Ghost you can follow these instructions.

Note that we do not use cookies, we do not listen to the DNT header (as we collect no personal or private information which could "track" people), we only durations when a user has more than one page visit, and pre-rendered pages are not tracked.

If a <link rel=”canonical” href=”PATH”> exists, then that will be used for the hostname & pathname.

← Return to support