DEV Community

Cover image for Self-hosted analytics with umami on Vercel
Vincent Voyer
Vincent Voyer

Posted on • Updated on

Self-hosted analytics with umami on Vercel

EDIT Sep 4, 2020 After having stability issues with self-hosted Umami. I decided to use Fathom Analytics and have been happy about it since then. I especially like the automated weekly email report on all my websites. Get $10 off by using my link:

Umami is a self-hosted open-source alternative to Google Analytics. It provides simple and fast website analytics for your projects. It is built with Next.js and can run on MySQL or PostgreSQL. I believe it's a recent project and you can read more on the associated Hacker News discussion:

Here's how it looks:

Screenshot of an example umami dashboard

You can even share public pages of your analytics!

I just started releasing products like Next.js News and wanted to have some information on the people visiting my website.

So far the products I knew about were:

I am ready to pay for services, but the idea of having a self-hosted analytics service that was good enough was interesting. So let's see how to install umami on Vercel.

1. Create a database

For Umami to work, you need a database. I went for the latest version of PostgreSQL on an AWS t2.micro which fits their free tier. But use whatever you want.

2. Create the necessary database tables

Use the provided SQL dumps:

  • schema.postgresql.sql
  • or schema.mysql.sql

You can find them here: It will also create the first user.

I use to connect to my local or production databases and execute queries on them.

3. Create a new project on Vercel

Directly import the project from, Vercel will fork it on your GitHub account.

Screenshot of Vercel's new project window

4. Configure the Vercel project

Change the build command for: npm run build-postgresql-client && npm run build if you're using PostgreSQL. Or npm run build-mysql-client && npm run build if you're using MySQL.

Add two environment variables:

  • HASH_SALT, used to encrypt passwords in umami database. It should contain a random string. You can generate good ones with 1password's strong password generator
  • DATABASE_URL, It's the full url to access your database. It should look like this: postgresql://dbuser:dbPassword@dbHost[:dbPort]/dbName

This is all you need, for details you can have a look at umami's install documentation.

Now you can click on deploy!

5. Login to the umami UI

Go to your newly created Vercel application and login with:

  • user: admin
  • password: umami

Change your password immediately.

6. Add websites

Now you can add some websites, get the tracking code, add it to your code annnnd DONE. You now have a fully functional self-hosted analytics that looks good and is sufficient for a start.

PS: Since what is deployed is a fork, you will have to update your fork to benefit from umami new features. See GitHub documentation on how to sync a fork.

Thanks for reading!

If you enjoyed this post, follow me on twitter at @vvoyer and share the article for your followers.

Top comments (10)

offirmo profile image
Offirmo • Edited

This looked good! Until I had a look at the feature set of umami :( It doesn't support custom events, which are great for a deeper dive of the user's activity: custom events
However, the point about bypassing ad blockers is good! (also not feeding the Google monopoly)

shubhamverma profile image
Shubham Verma

What do you mean by custom events?
If I am not wrong I think Umami supports it.

vvo profile image
Vincent Voyer

Maybe the other solutions in the article are providing custom events. It was fun and easy to setup umami but ultimately maybe I'll use something else. For now it's good enough

adriangrigore profile image
Adrian Emil Grigore

I'm pretty sure I'm going to build an analytics system around these

bitdweller profile image
Pedro Pimenta

Great! I'm definitely going to check this. I'm using Ackee currently, which is very nice but too simple for my taste. I saw your post on the Github Issue :)

vvo profile image
Vincent Voyer

Oh wow did not even know Ackee, well it seems Ackee has more features than umami actually :D

bitdweller profile image
Pedro Pimenta

Oh may be but it doesn't have country/region and I'd like to have it. Yes, it's by option, and makes sense for privacy, but I'd still like to have it :)

accudio profile image
Alistair Shepherd

Great article! I found it looking at how to roll out my own Umami instance. I'm interested to know what stability issues you were having that prompted the switch to Fathom?

jentanbernardus profile image
Jentan Bernardus

Here I am a few years later reading this post.. and also wondering what those stability issues were. Maybe it has been fixed meanwhile.

@vvo Have you rechecked umami lately or stuck with Fathom?

jainilprajapati profile image
Jainil Prajapati

How can I host it through Cpenal