Photo by Anne Nygård

Self-hosted analytics review 2021

I've been hosting my own web analytics with Countly on Digitial Ocean for awhile now.  It's pretty maintenance free.  I had one hiccup where the logs filled the disks, but otherwise, it just keeps working.  However, the version is old, and newer versions no longer work with my setup.  At some point, I'll need to find another solution.  There's been a lot of activity lately in the space and I took another look at some new options to try to find something free or easier to manage.

Plausible

Price: $4/mo when paid annually, no free plan

Self-host: Yes, and have a docker container.  However, depends on external postgres and clickhouse db. 

Plausible looks great.  If I had to choose something hosted, they'd be my pick.  

Posthog

Price: Free for less than 10k visits, scales up

Self-host: Yes, but it's still limited.  They do have a self-contained docker container.

Looks decent and I was able to get it running myself with little issue.  However, the self-hosted version is still limited to one project unless you buy a license.

Counter.dev

Price: Free

Self-host: Maybe.  But there are no directions and no Docker container.

This looks pretty good.  I worry how long it will last with no revenue model.  It also has some limitations, in that it only tracks the first page someone visits, not all of them.  Checkout the Github repo for more info.  If you could figure out how to self-host, this might be a good fit.

Self-hosting with Fly.io

Although I really like Digital Ocean, the cheapest option is still $5/mo.  A new option, apparently meant for developers, is Fly.io.  It doesn't have much of a UI, most everything is done with a CLI.  It has a generous free layer, allowing you to run 3 containers.  The default container has a very low 256M of RAM, but I think you can increase that to 2G at no cost. 

flyctl scale -a <appname> memory 2048

The pricing is unclear on this point. 

The other really nice thing about Fly is that they provide an SSL proxy in front of your apps for you.  This can save you the hassle of setting up nginx proxy and lets encrypt or cloudflare.

Countly

I tried to get the latest Countly docker image working on Fly, but couldn't get it going.  Mongodb failed to start, I presume because of something to do with the data directory.  With more time, this could probably be made to work.

Plausible

Although they provide a Docker image, you really need three docker images: Plausible, Postgres, Clickhouse.  Plausible provides a docker compose, but Fly only supports Dockerfiles.  I briefly tried to link three separate Fly apps together to make it work, but failed.  I suspect with time, this could be made to work.  And could work pretty well, since you could run all three parts on the free tier, each with 2G of RAM.

Posthog

I got this working well on Fly.  Just be sure to use the self-contained Docker image at posthog/posthog:preview, increase ram to 2048, and use internal port 8000.  However, the self-hosted version is still license limited and only supports one domain.

Counter

I really hope someone gets a container for this.  They use Redis to store data, and Fly provides a free hosted Redis service.  So it could provide a nice separation of front-end and backend.  I looked a bit at the code, and it seems they haven't checked in everything they're using.  For example, there are references to a production.sh that doesn't exist.  This would probably require some serious tinkering to get Dockerized.

Conclusion

I still have a strong preference for self hosting.   I use an ad blocker, so do many others.  When you self-host, you get better data.  Any new cloud analytics host will eventually end up blocked.  I think external tracking will eventually be a dead end.   For now, I plan on sticking with what I have.  If I had to move now, I'd move to a paid Plausible.  If I have time and gumption, I'll probably try to get Plausible working in Fly.  What I really hope, is that Netlify Analytics eventually offers a free tier.