I’ve been looking for an alternative to Google Analytics, 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.
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.
To create a DO server with Dokku preinstalled, simply use this link: https://www.digitalocean.com/products/one-click-apps/dokku/.
If you choose a different provider, make sure to install dokku on your server.
2. Setup a domain
This step is important in order to be able to use
https later on. I will leave this to you, but essentially, you need to add a DNS record like so in your DNS provider:
* 1800 IN A 22.214.171.124
I’ll use domain
analytics.me.com in the rest of the post.
3. Setup dokku app
SSH into your new or existing server. Make sure you’re running the latest version of dokku:
apt-get update apt-get install -qq -y dokku herokuish sshcommand plugn
Create a dokku app:
dokku apps:create fathom
Create a MySQL database:
dokku mysql:create fathom-database dokku mysql:link fathom-database fathom
Configure environment variables:
dokku config fathom FATHOM_SERVER_ADDR=:8080 dokku config fathom FATHOM_GZIP=true dokku config fathom FATHOM_DATABASE_DRIVER=mysql dokku config fathom FATHOM_DATABASE_NAME="fathom-database" dokku config fathom FATHOM_DATABASE_USER=mysql dokku config fathom FATHOM_DATABASE_PASSWORD=<password> dokku config fathom FATHOM_DATABASE_HOST=dokku-mysql-fathom-database:3306 dokku config fathom FATHOM_SECRET=<secret>
For the MySQL password, you can see it by running:
$ dokku mysql:info fathom-database > ... > Dsn: mysql://mysql:<your password is here>@dokku-mysql-fathom-database:3306/fathom-database > ...
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:
Add your server as the remote:
git remote add dokku firstname.lastname@example.org:fathom
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@example.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.