How to use Fathom Analytics with Gatsby.js
Fathom Analytics works great with Gatsby.js. A huge thank you to Lars Graubner for building the original Gatsby plugin. We've now written these instructions so that you don't need to use any plugins to get Fathom working in Gatsby.
- In your terminal, navigate to your Gatsby project
cp .cache/default-html.js src/html.js
- Add the following snippet just before
</head>in that file (remember to add your own site ID and your custom domain, if you have one)
<script src="https://cdn.usefathom.com/script.js" spa="auto" data-site="ABCDEF" defer></script>
And that will work out of the box. We have heard from others that you may need to adjust the formatting to JSX but it worked great like this during testing.
To learn about all the options we offer, read our advanced documentation here.