Setting up your own Google Analytics (Umami)
Hosting your own Google Analytics (Umami)
I recently saw a post on X, where a user said how fascinated he was when switching from the not particularily user friendly UI of Google Analytics to an open source alternative called Umami. My experiences with Google Analytics are limited but as I saw Umami being GDPR compliant by default (more info: Umami FAQ), I wanted to give it a shot.
Btw, Umami means delicious savory taste and originates from Japan where it was identified in 1908. Almost a century later, In 2002, it has been discoverd that the human tongue can distinctively taste umami besides the four typical tasts: sour, bitter, sweet and salty. Now let's get a taste of Umami Data Analytics.
Still new to all this, I checked the website first to get an impression. The data analytics platform offers:
- Traffic Analysis (How many, when etc)
- Visitor Analysis (Who are the visitors, where do they come from etc.)
- Capture Events (like Button clicks)
- Filters for Data Aalytiics
- Trend Detection
This sounds like exactly what I was hoping to get from a data analytics platform, so I went ahead and checked out the GitHub Repository. Give it a star, if you decide to use it!
Self-Hosting vs Umami Cloud
It's not such an obvious choice to me. Self hosting is great and all but the Umami Cload offers some generous Free Tier usage.
- Up to 3 Websites
- Up to 100k events per month
- 6 months of data retention
So, to be fair, this for now seems absolutely enough for me and I would have gotten around some of the headache I describe further down below. But I also wanted to face this challenge and to try self hosting it. It is always good to know if you scale beyond the Free Tier if you have an easy route for self hosting vs. vendor lock-in. So, self-hosting it is!
Problems when Installing / Self Hosting
Whenever I start to try out a new tool on my VPS (Virtual Private Server), I especially look for a uninstall.sh or a docker image. I burnt myself too often not to think about the way back before installing something on the machine which serves my homepages / SaaS. So I was pleased to see a docker image to use.
Technically, it sounded straightforward. Change a few things in the docker-compose.yml file and spin it up. But as always, I got to do some preparations first:
- Register a sub domain on Cloudflare
- Protect the sub domain with ZeroTrust (be safe)
- Set up NGINX which points to a custom port (not 3000)
- Run Certbot for SSL certificates
- Change the docker-compose.yml (including a port remap: custom -> 3000 (inside docker)
Having set up all this I was happy to see the login screen on my custom domain. But this is where things turned South.
The < Character JSON Parsing Error
I was hit in the face with this error message, when trying to login with the default user:

This took a bit for me to resolve but I finally found the reason: The Cloudflare Proxy threw a Challenge via .html and Umami expected to get a JSON response. This was more obvious when I looked into the developer console.
I then changed the DNS entry for the umami subdomain to DNS only and voila, it worked.
Adding my Sites to Umami
Now with the setup complete, I could finally add my webpage to my Umami Server. When you add a site to the dashboard, a unique ID will be assigned and you can get a code block to include on your webpage like so:
1234
<script
defer src="https://my-umami.myhomepage.com/script.js"
data-website-id="0cfe30f8-1b8e-47e1-8f3c-f5327c86fbd1">
</script>
The tracking code (0cfe30f8-1b8e-47e1-8f3c-f5327c86fbd1) allows umami to identify which webpage it was sent from. It is unique for every homepage. As most of my websites use next.js, you have to find a good place where to include this. One good option is the _app.tsx component. There wrap it into a Script (from next/Script) component and you are good. Make sure to deactivate extensions like uBlock Origin when you test it. Pay close attention to the network tab and you will see the request sent to your subdomain.
First Impressions
The interface / dashboard looks clean, minimal and I like it very much. It works quite good and I am still at the beginning of getting to know all the functions / ways to analyze the data. So I will update this post when I have some more mileage in with this tool. So far I can fully recommend doing this.