DEV Community

Cover image for How I Replaced Google Analytics With a Private, Open-Source & Self-Hosted Alternative
Michael Hoffmann
Michael Hoffmann

Posted on • Originally published at on

How I Replaced Google Analytics With a Private, Open-Source & Self-Hosted Alternative

For me, it is important to see analytics about my portfolio website. This way, I can see which posts got the most views, which country my users are from, and which browser & operating system they are using. The simplest solution to add analytics to your site is Google Analytics as it is free and easy to set up. But as we all know, this service is only free as we pay it indirectly by providing data to it. What you need to know about Google Analytics and privacy.

In this blog post, I will show you how I replaced Google Analytics with Umami which is a simple, easy to use, self-hosted web analytics solution.


I chose Umami because it

Umami Intro

Umami does not provide a hosting solution. Therefore, we need to host the service on our own. All you need to get Umami up and running is a database (either MySQL or PostgreSQL) and a server that can run Node.js (10.13 or newer). Check the list of available hosting solutions.

I will show you two different approaches I tried to host Umami.

Running on Heroku

Heroku is a container-based cloud Platform as a Service (PaaS). Developers use Heroku to deploy, manage, and scale modern apps. The platform is elegant, flexible, and easy to use, offering developers the simplest path to getting their apps to market.

You can read more about Heroku on their “What is Heroku?” page.

We can host Umami and a corresponding database for free on Heroku. The setup is well described in the Umami documentation.

To get it running, I just had to modify the npm start script command to include the Heroku port:

"start": "next start -p $PORT"
Enter fullscreen mode Exit fullscreen mode

Using Heroku is for sure the easiest & fastest way to set up a running Umami instance but there is one drawback: It is expensive.

I collected analytics data from my website for about 2 days and I quickly realized that the free “Hobby Dev” Heroku Postgres plan will not be enough.

Heroku Postgres Ressources

This free plan includes 10,000 database rows and I filled ~1000 per day. So the free plan would be reached in about 10 days. The next “Hobby Basic” plan for 9$/month would include 10,000,000 rows which would last for approximately 27 years (assuming 1000 new rows per day, so no increasing traffic on my website). The “Standard 0” plan for 50$/month provides unlimited rows but this is way too much money I would spend for a self-hosted analytics solution.

Running on DigitalOcean & Vercel

An alternative to Heroku is to host the database on Digital Ocean and Umami on Vercel.


Digital Ocean is an affordable cloud hosting provider. Starting with 5$/month you get a cloud server for personal use and can scale it up as needed. Using this link you get a $100 credit for the first 60 days.

I host a MySQL database on DigitalOcean which required these steps to set up:

  1. Initial setup the server with Ubuntu 18.04
  2. Install MySQL on Ubuntu
  3. Setup the MySQL database schema with the Umami MySQL schema
  4. Allow remote access to the database

Digital Ocean Droplet

DigitalOcean also provides a Node.js droplet template that comes with Node.js, Ubuntu, and Nginx to host the Umami frontend. We will instead use Vercel as it is completely free.


Vercel is the company behind the framework Next.js which is used by Umami and they provide a free frontend hosting service. As you can imagine, it is really easy to deploy a Next.js application on Vercel as both applications are developed by the same company.

The setup is described in the official documentation.

Vercel Deployment

If you now open the deployed Vercel app at <app-name> you need to perform these steps

This should result in a working private, open-source, self-hosted analytics solution:

Umami DashboardUmami Realtime


I can sleep better as I now know that no more data is sent from my website to Google. I still have the possibility to track my website analytics but in a simpler and privacy-focused way. Setting up Umami is quite easy if you are familiar with software like Ubuntu and MySQL/Postgres.

Of course, I know need to pay some money to store this analytics data on my server but for me, it is worth the money.

Top comments (12)

maureento8888 profile image
Maureen T'O • Edited

Umami is an interesting analytics platform - I’ve not heard of it!

I’ve also heard of Fathom Analytics as an alternative to Google Analytics and it’s super cool! They’re less costly than Umami and the UI is beautiful too. Their analytics $14/mo (base tier) for 100,000 page views across unlimited sites 😯

miku86 profile image

Hey Michael,

why did you choose Umami, e.g. over Matomo?

mokkapps profile image
Michael Hoffmann

Matomo is not open source and Umami looked simpler in its documentation, feature set and UI.

glennmen profile image
Glenn Carremans

Matomo has an open source self hosted option that works very well and is also privacy focused.

george profile image
George Nance

Matomo is open source

Thread Thread
mokkapps profile image
Michael Hoffmann

Ok thanks, my fault!

frans profile image
Frans Allen

I haven't used Google Analytics in a very long time, Umami is a solid solution for privacy-focused analytics. And I am proud to use this tool at Statically CDN. Nice to read this blog, Michael!

whitekamenrider profile image

(Hi, I'm extremely new to this whole data being sold for profit, so please forgive if this is a stupid question.)

What is the net negative for Google having your website's analytics data? Who could they possibly sell it to that would be an issue and in what way would this analytical info be harmful to you as a business owner.

I believe this question will help a lot for the other newbies who are seeing this blog post in the Google suggestions (like I did).

mokkapps profile image
Michael Hoffmann

Sure, I referenced this article in my blog post:

shubhamverma profile image
Shubham Verma

Even I use it for my Portfolio. Its clean, simple and provides good data.

radiomorillo profile image
Stephanie Morillo

I'm a big fan of GA alternatives; I myself use Matomo. Great article, Michael, thanks for sharing!

papaponmx profile image
Jaime Rios • Edited

This article is awesome, thanks for sharing!