Add Fathom Analytics to your Obsidian Publish site
Today I figured out how to embed the tracking code for Fathom Analytics into an Obsidian Publish website. It's easy.
- Create a file in the root of your Obsidian Vault called
publish.js– You'll need to use an editor like VS Code for this as Obsidian won't handle it. - Add this code to that file, replacing with your actual site code.
var fathomSnippet = document.createElement('script');fathomSnippet.defer = true;fathomSnippet.setAttribute('data-site', '');fathomSnippet.src = 'https://cdn.usefathom.com/script.js';document.head.appendChild(fathomSnippet);
- Use Obsidian to publish the
publish.jsfile just like any other file.
That's it!