Preface

Tracking: the final frontier of capitalism. This is the voyage of a curious old nerd and its mission of exploring homelab universe, to seek new technologies and software, to boldly track where no man has tracked before!

final_frontier

Well, technically, tracking is not native to, and exclusive of, capitalism. It is present and overused in communist regimes too. It is about control, regardless of the system.

Control

So, I was re-polishing my homelab, and a couple of thoughts crossed my mind.

  • I wanted to have simpler analytics for my blog
  • What is the best tool to visualise nginx access logs?

Now, I always wanted to have some form of tracking for this blog, just to keep track of where visitors are coming from and which pages they view. Period. So, years ago, I installed Matomo, the open-source alternative to Google Analytics. I paid for my DB instance on my hosting provider, and I was content. Ultimately, what I wanted was to be able to see from which country people landing on my blog are coming from.

matomo_screenshot

In regards logs analysis, I naively never used a tool until recently. There will be a small post about that later. For now, I am gonna talk about tracking.

Matomo

Matthieu Aubry created Piwik a long time ago. That became Matomo in due time. Nowadays, it is the de facto alternative to Google Analytics. Matomo is extendable and very comprehensive. For a professional need, it is highly recommended. It provides

  • Web and mobile analytics - Advanced analytics
  • AB testing - Creation, tracking and analysis of A/B testing
  • Custom reports - Definition of custom reports
  • Heatmaps - Track clicks, mouse movements and other activities on the website and offer them in a heatmap to facilitate understanding where and how visitors are interacting on the page
  • Session recordings - Manage recordings of the page view with the duration of the page view, the viewport resolution, the location, device information, and more.
  • Funnels - Complete control over Funnel definition and managing. Documentation.

And many more features. Honestly, I was using not even 5% of what Matomo has to offer. That's why I looked for other solutions.

Umami

Umami is another alternative to Google Analytics, started by Mike Cao. It also provides things like Web analytics to get insights from traffic, a breakdown of visitors by location, device, time. Offers real-time dashboards too.

  • Web Analytics - Standard analytics
  • Traffic analysis - Including source
  • Visitor analysis - Breakdown by device, browser, location and so on
  • Custom events - Track specific events, like a form submission
  • Real-time data - Immediate processing of data

A few things that I would like to add are:

  • More immediate UX to me
  • Fewer functionalities and less configurations to do for simple use cases
  • Easy installation with docker

Migrating

Now, before moving away from Matomo and switching to Umami, I had to answer two questions:

  • Can I move the data from one system to another?
  • Can I easily integrate Umami in my blog (Grav)? Or Do I have to manually change the template to include the tracking code?

Data migration

Honestly, I could not have been luckier. Tobias Pankner made a very easy tool to export data from Matomo in a way that it can be imported into Umami. The documentation is super clear. You just need to get some data from Matomo. You need to do a few things.

  1. Create the Website on Umami
  2. Fetch the UUID of the Website you just created (I saved that to a file)
  3. Fetch the site ID of the Website on Matomo
  4. Create an API token for Matomo to dump the database (I saved that to a file)

Where to get the website ID from Matomo

menu_website_id

Where to generate the token in Matomo.

menu_security_api api_token

It also comes as a Python software, so you may wish to have a virtual env before we proceed.

virtualenv .env
source .env/bin/activate
pip install -r requirements.txt

Once you have all the information, and the Python environment, you can run the script

python matomo2umami.py <address_of_matomo> <site_id_on_matomo> $(cat token.txt) $(cat umami_site.txt) --start-date 20200-01-01 --end-date 2025-12-04 -o complete_migration.sql --batch-size 5000 --days-per-request 10

migration

Once you have the file, you can copy it over to the container (for me, the name is tracking-db) and import it.

docker cp complete_migration.sql tracking-db:/
docker exec -it tracking-db-1 psql -h localhost -U <username> -W -d <database_name> -f complete_migration.sql

This will ask for the password and then insert all the data.

umami_history_from_matomo

Grav integration

Also, this was a smooth and short trip. There is a plugin for Grav that enables you to integrate seamlessly, without having to edit the theme. You just need the site ID from Umami.

Conclusion

Umami satisfies my needs regarding my blog. While, at the time, I will strongly recommend Matomo for any non-amateur project, Umami is growing a lot, and I think it is the right choice for personal websites.

Next Post Previous Post