Track 404/error pages
If you'd like to track what the URL is for 404 pages on your site, you can dynamically add the URL of the page to the event name. By doing this, you'll see which pages people are visiting on your site that don't exist (so you can either redirect those pages or fix broken links to them).
For example, if someone visited usefathom.com/poodcast (which doesn't exist), an event in Fathom would be created called 404: /poodcast
to let you know someone visited that URL, which doesn't exist.
Here's a couple of ways you can do this:
1. Detect 404 via template page
If you're using a template page for your 404 page (as most CMSs do), you can detect if the page returned a 404 by adding the following code to the footer of your 404 template page:
<script> window.addEventListener('load', () => { const path = window.location.pathname; fathom.trackEvent('404: ' + path); });</script>
2. Detect 404 via page title
If your 404 page has a title (the text that shows in the browser tab) that contains either "404" or "Page Not Found" (or both), you can detect if the page returned a 404 by adding the following code to the footer of your site:
<script> window.addEventListener('load', () => { const title = document.title; if (title.includes('404') || title.includes('Page Not Found')) { fathom.trackEvent('404: ' + window.location.pathname); } });</script>