Learn how-to add self-hosted Fathom Analytics to your Jekyll theme.

Add the following code snippet in between the <head></head> HTML tags in your Jekyll theme's default.html file:

{% if site.fathom_analytics %}
<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, '//domainname.com/tracker.js', 'fathom');
fathom('set', 'siteId', '{{ site.fathom_analytics }}');
fathom('trackPageview');
</script>
{% endif %}

Ensure you change the domain name where your self-hosted Fathom Analytics is located on line 11 of the above code snippet.

Add the following to your theme’s _config.yml file:

fathom_analytics: ABCDE

You should change ABCDE to your property's tracking ID number.

Share this post