Self-Hosting Analytics For Indie Projects

My little adventure of setting up affordable analytics for my personal apps

The Situation

I needed a simple way to count page views for a website I was building. There are many services out there that offer this. I had the following criteria to help me narrow it down:

  • It should have a generous free tier - I'd like to use one service for all my projects, most of which are hobby.
  • It should be privacy focused - which means non-essential cookies and personal data collection are out. This ruled out Mixpanel. I've been happily using it in mobile apps, but sadly it requires the use of cookies in the case of web apps.
  • It should be quick to set up for my basic needs.

The Options

I looked into many popular modern services - Plausible, Fathom, PostHog, and more.

I really like and respect what some of them are doing for privacy, and I'd say they're quite affordable too...if you are making enough off of your projects to cover the costs. I'm not there with my apps yet.

On top of that, the few free tiers I found, were not enough for my needs (2500 events? That could easily be used up by just one project making $0/month).

Taking all of that into account, I decided to look into self-hosting. I had read that a cheap server would be more than enough for the task.

At this point, a little voice popped into my head:

"I think that's overkill."

"Yeah, but I'm tired of researching all this. Plus, it's a way to keep costs low until there's enough revenue."

"True, but you know it's gonna take triple the time to learn to self-host, right? Unless...wait. All of this...it's just a distraction, isn't it? A way to take a break from everything else for a bit?"

"Maybe. Is there...really anything wrong with that? At least I'll learn something new. Plus, it'll be one less thing to be afraid of in the world of coding. I think I need that confidence boost right now."

"Alright. If you really need to...fine. Guess it's goodbye to sleeping on time tonight...Hope it's worth it (you know it's not)."

Okay, okay, that was a bit distracting, I know - back to my search for a self-hostable analytics package.

After a bit of Googling (for Reddit posts), a couple of options stood out - Plausible and Umami were the most recommended. I chose to go with Umami, for no particular reason.

The Plan

This was the rough plan:

  • Set up a Digital Ocean 'droplet' (a VPS)
  • Install Umami on it using its prebuilt Docker image
  • Secure the server according to standard practices
  • Ride off into the sunset with a super-affordable analytics setup for all my projects!

The last one is a bit too optimistic, we'll get to that.

The Process

I know very little about servers. The most I've done before is deploy one Laravel project on a droplet using a nice GUI (Laravel Forge). For the rest of my web projects, I've been spoiled by the abject convenience of Next.js + Vercel.

So naturally, executing this plan involved a very generous helping of ChatGPT (and a smattering of Claude). More on that later.

Here's the general order of how everything went down:

  1. I rented a basic droplet with 1GB RAM ($6/mo) on Digital Ocean.
  2. Opened up the Droplet's Console (the server's version of Terminal), and installed Umami using its prebuilt Docker image. The image includes the app + a Postgres database to store the tracked events.
  3. I then purchased a custom domain ($8/yr), and connected it to the droplet.
  4. Next, I set up nginx (pronounced 'engine x') using the console. Basically, nginx is how you configure how to handle which type of incoming requests.
  5. Configured rate limiting in nginx to protect against spam attacks.
  6. Used Certbot to add an HTTPS certificate for the custom domain I bought.
  7. Set up Fail2Ban. Fail2Ban is a process that detects and bans IPs that seem suspicious.
  8. Finally, I proxied all requests to the custom domain through Cloudflare for added security.

It's all very technical, especially for someone like me who's new to backend development. So I have to admit, I'm not sure I would've been confident enough to attempt this without ChatGPT there to help me get unstuck (and I got stuck pretty much every 10 minutes).

The other nice thing is, LLMs can provide instructions that are tailored to what I specifically want to achieve. If I'd relied on Google only, I'd have to piece together parts of different articles (all of varying quality) to get what I wanted.

All in all, the whole process took me about 8 hours to get through.

All Done! (Or is it?)

Phew! That was a lot to take in (for me, but hopefully not for you reading this). I now have analytics that can handle a virtually unlimited number of events per month. Yay!

However.

I follow people in the indie space who deal with servers. People much smarter and more experienced than me. And they all encounter frustrating issues with servers at some point, and due to a wide variety of reasons. It's why they don't particularly enjoy doing it.

So I'm fully expecting to run into issues down the road too. No idea when that point will be...but that's alright. It was fun taking on this challenge, and the site will serve my needs quite well while it lasts. I'm satisfied.

I was telling my friend all about this little adventure, and as we talked, she read through the pricing page of Umami's managed service (where they take care of the hosting for you). Specifically the free tier.

100K monthly events free.

FFFFFUUUU-