How to Install Umami on Linux and Add Analytics on Your Website

Spread the love

Umami is a lightweight and privacy-focused analytics software for websites and web apps. It is one of the best free alternatives to Google Analytics and it provides an easy-to-use interface that can look at and analyze incoming web traffic similar to Google Analytics. Here, we show how to install Umami on Ubuntu Linux and guide you through the process of adding analytics for your website.

Content

Why Use Umami for Tracking Site Analytics

One of the biggest selling points of Umami is that it’s a website analytics software that anonymizes all data about its users. This makes Umami incredibly attractive to webmasters that want to look at their website’s performance without compromising the privacy of their visitors.

Another reason to use Umami is that it’s GDPR-compliant and it doesn’t rely on cookies to track a user’s session. As such, you don’t need to provide any additional opt-in banners for your visitors, making your website smoother and easier to navigate.

Lastly, Umami is completely free of charge and it doesn’t take a lot of system resources to run properly. This means that you can install Umami on your existing server and enjoy free analytics for your websites.

Obtaining Docker and Docker Compose for Umami

The first step in self-hosting your own analytics with Umami is to obtain both Docker and Docker Compose for your Linux machine. To do that, fetch the signing key from the Docker project’s website:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Note: This section focuses on installing Docker for Ubuntu. If you’re using a different distro check out our general guide to installing Docker on Linux.

Create a new repository file under “/etc/apt/sources.list.d/” using your favorite text editor:

sudo nano /etc/apt/sources.list.d/docker.list

Paste the following line of code inside your new repository file:

deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu noble stable

Make sure that your system is completely up-to-date and working correctly:

sudo apt update && sudo apt upgrade

Install Docker, Docker Compose, and the additional dependencies for Umami:

sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-buildx-plugin nginx git

Installing Umami

Navigate to your user account’s home directory, then pull the Umami Git repository from the developer’s Github page:

cd ~ && git clone https://github.com/umami-software/umami.git

Go inside the Umami Git repository, then open the prebuilt Docker Compose file using your favorite text editor:

cd ~/umami
nano ./docker-compose.yml

Scroll down to the “environment:” category, then replace the value of the APP_SECRET variable with a random string of characters.

Note: You can generate your own random string of letters and numbers by running: cat /dev/urandom | tr -dc 'A-Za-z0-9' | fold -w 32 | head -n 1.

Save your Docker Compose file, then run the following command to build and install the Umami container:

sudo docker compose up -d

Confirm that your Umami instance is running by listing the available Docker Containers in your system:

docker ps

Good to know: learn how to manage your Linux servers and Docker containers with XPipe.

Securing Umami with an SSL Reverse Proxy

At this point, you now have a self-host Umami analytics instance running on port 3000 in your Linux system. In order to access this service over the internet, however, you need to pass it first through an SSL reverse proxy.

Start by adding a new “A” DNS record to your domain registrar pointing to the IPv4 address of your Umami server. In my case, I will set my “A” record to “umami.myreallygreatserver.xyz.”

Check if the “core” snap package is already in your server:

sudo snap install core

Install the Certbot snap package from the Electronic Frontier Foundation (EFF):

sudo snap install certbot --classic

Create a new site configuration file for your SSL reverse proxy:

sudo nano /etc/nginx/sites-available/umami

Paste the following block of code inside your new site config file:

server {
 
        server_name SUBDOMAIN.YOUR-ROOT.DOMAIN;
 
        location / {
                proxy_pass http://127.0.0.1:3000;
                proxy_http_version 1.1;
                proxy_redirect off;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header X-Forwarded-Proto https;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $host;
        }
}

Replace the value of the “server_name” variable with your domain name.

Save your new site config file, then create a symbolic link to “/etc/nginx/sites-enabled:”

sudo ln -s /etc/nginx/sites-available/umami /etc/nginx/sites-enabled/

Check your Nginx config files for errors, then run systemctl to start your reverse proxy:

nginx -t<br>sudo systemctl reload nginx.service

Register your Umami server to the EFF:

sudo certbot register --agree-tos -m YOUR@EMAIL.ADDRESS

Run the following command to generate your site’s SSL certificate:

sudo certbot --nginx -d SUBDOMAIN.YOUR-ROOT.DOMAIN

Confirm that your Umami instance is working properly by opening a web browser and navigating to your subdomain.

Adding Umami Analytics to Your Website

By default, Umami sets your default username to “admin” and your password to “umami.” This can be incredibly insecure and it is advisable to change it on the first login.

To fix this, click the user icon on the dashboard’s upper right corner.

Click the Profile link on the small pop-up menu.

Click the Change Password button under the Password category.

Type “umami” on the Current Password textbox, then provide your new password on both the New Password and Confirm Password textboxes.

Click Save to apply your new password, then select Dashboard to go back to Umami’s main screen.

Adding a Website to Track in Umami

To add a new website to your Umami instance, click the Settings link on the page’s top navigation bar.

Click the Add Website button on the page’s right side.

Doing this will bring up a small window where you can provide the name and the address of your website. In my case, I will provide “Website” for the name and “web.myreallygreatserver.xyz” for the domain.

Click Save to commit your changes, then click Edit on your website’s entry.

Go to the Tracking Code tab, then copy the HTML snippet to your clipboard.

In your website, paste the HTML snippet inside the <head> section of your file. You need to place the tracking code in every page that you want to track.

Confirm that Umami is now properly tracking your website’s analytics by visiting your website, then opening your Umami’s dashboard page.

Umami is not the only free analytical software you can use. Check out some of the best Google Analytics alternatives here.

Image credit: Myriam Jessier via Unsplash. All alterations and screenshots by Ramces Red.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Ramces Red
Staff Writer

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Leave a comment