A privacy respecting approach
Umami is the tool I’m using for collecting and viewing the user analytics. My needs are simple—I just want to know how popular I am.
Some prior infrastructure that is already setup is Kubernetes, Flux, Nginx Ingress, Certificates, and Hugo. I’ll get to posts describing the full setup at some time. In my git repo I have the following files for Umami
kustomization.yaml is simple and is just a reference to the other two.
umami-secrets.yaml is an opaque secret encrypted using sops. Unencrypted it has the following contents.
Note that I manually created the postgres user and database with values that match the connection string above.
umami.yaml has the following contents
hostname will need to be changed to dodge ad blockers. Use the data only for good, not evil.
Shoutout to christianknell for the helm chart.
Navigate to the URL defined in the above ingress definition. Default username is admin and the default password is umami. Change these ASAP.
Go to the settings and add a website:
Once that is done, click on the code button to get the data you need for the next part.
Analytics in Hugo
How to do this will depend on the theme. I’m using the PaperMod theme and here’s how I did the next part.
First, I created a partial file. Hugo will look in this directory and overwrite the contents of your theme with what is in here. PaperMod has
extend_head.html for custom header resources like this.
The parameters referenced there are defined in Config.toml
This data comes from the Umami settings for the website. And, now after visiting the website I go back to umami and see it working:
Not very popular.