Hosting your own analytics with Fathom

I’ve been looking for an alternative to Google Analytics for a whilte. Either a beautiful, simple, easy to use Open Source project or a reasonably priced paid service. I haven’t found any decent paid services priced at around $1 per site per month. But I have found a couple good options for hosting your own analytics – and those are Countly and Fathom. In this post, I’ll show how you can quickly setup Fathom on your own server.

Why an alternative to Google Analytics? That is a big question. No, I don’t think Google is evil. But they are big. I think them having an absolute monopoly on tracking users across the sites is a little questionable. I don’t know in what ways they use that data (e.g. is it used to improve Google Search rankings?), but GA is probably giving the company a pretty big competetive advantage. Google already tracks people going through their search portal, tracks people on sites that serve ads, but we also fill all the other gaps by providing Google with free GA data. Too much power? Anyway, I will leave deep diving into this question for another day and will focus on how you can run Fathom for just $5 a month.

What is Fathom? “Fathom Analytics provides simple, useful websites stats without tracking or storing personal data of your users.”. Read more about it on their site or view a live demo.

Judging by their public analytics ↑, looks like Fathom has been getting a lot of attention recently, good for them! Are more people seeking out alternatives to GA?

Fathom is written in Go and is using MySQL database for storage. We will deploy it to a DigitalOcean server and spin it up using Dokku. It should only take about 10-20 minutes. OK, let’s do this!

1. Create your server

I can highly recommend DigitalOcean, but you can of course use any provider, you like. With DigitalOcean you’d be paying $5 for the server or $6 if you also turn on the automatic backups.

For the Fathom secret, you can generate one by running the command below or alternatively by using DuckDuckGo:

openssl rand -base64 128 | tr -d /=+ | sed 'N;s/\n//' | cut -c -64

4. Create a git repo

Create a GitHub (or other) git repository and add Dockerfile with the following contents:

from usefathom/fathom:latest

Add your server as the remote:

git remote add dokku dokku@analytics.me.com:fathom

5. Deploy!

You should be ready to deploy your very own instance of Fathom:

git push dokku master

After this completes, Fathom should be running on your server. But there are a couple more steps to complete.

6. Fix ports

Unfortunately, there is some mismatch between Fathom and dokku defaults. Simply execute the following on your server to map the right ports.

dokku proxy:ports-add fathom http:80:8080

Note: this might be avoided by setting FATHOM_SERVER_ADDR=80, but I haven’t tried that and I didn’t want to provide unverified instructions.

7. Setup domain and HTTPS

Configure the domain for the dokku app:

dokku domains:add fathom analytics.me.com

Then setup https, run this and follow the instructions:

dokku letsencrypt fathom

8. Create user

Enter your Fathom Docker instance:

dokku enter fathom

And create a user:

./fathom user add --email=your@email.com --password=secret

Make sure to add this password to your password manager as there is currently no (easy) way to reset this password. Worst case, you can create another user.

Note: this step is important, until you create a user, Fathom interface stays public and can be accessed / modified by anyone.

This is it 👏! You should now have your very own copy of Fathom. Next, you should open your domain and setup your site or multiple sites there. The Fathom UI will provide you with sufficient instructions on what JS tracking snippet to use on your site.

Is this scalable? I don’t see why not, if you ever need to, you can always crank up your server to a beefier machine. You can use Dokku’s database backup feature or simply tick “Backup this server” in DigitalOcean control panel to make sure you don’t lose the stats.

While Countly has more features, e.g. it breaks down your visitors by country, I find Fathom closer to what I’m looking for – a really focused, minimal solution. I hope you’ll give it a go.

If you’re ok with $14/month, you can also use Fathom’s hosted solution: https://usefathom.com/#pricing. I personally find it a bit of a steep entry, but maybe I’ll switch once I prove that it’s a good long term solution.

Read Next

React has revolutionised UI development. It might not be the final paradigm and it doesn’t mean we shouldn’t be exploring new ideas. But in any case, React is awesome and a lot of fun to use. The core principle of React is that your entire UI is a function that takes some state… Continue →