What is it?
Given the following situation, I have a website and want to get some analytics. One could choose to use Google Analytics, but this means giving all your data to a company.
One of many options is to use Matomo, Matomo is a powerful privacy-first web analytics platform that gives you 100% data ownership.
In this blog I will depict how I have setup Matomo on my webserver and use nginx to forward traphic to it. Next I will give a super simple example how to integrate it in an existing Angular app.
Normaly, if a user goes to a website, the analytics data is gathered by a thirth party domain/website
This situation is totally fine and is used by a great amount of companies. But I want that my users only download content from the domain they initialy visited
What I desire
- DirectAdmin as webhost panel for the domain webstats.inexpro.nl (my personal company)
- Let’s Encrypt for the https certificate
- Matomo as analytics software
- MySql as database server
- nginx as reverse proxy
And then, we have a (after installation) working Matomo application
Put it all behind nginx
With the normal installation, if I then use it, the website visitor will be downloading files/scripts from e.g. timdows.com and then send traphic stats to webstats.inexpro.nl. In order to minimize the domains, I’ve created the following setup/solution for this.
The above solution forwards all requests from, in this case https://timdows.com/s.js to https://webstats.inexpro.nl/matomo.js
Also all the ping requets (that hold the actual analytics data) go to https://timdows.com/s.php
In an Angular app I can now add the following plugin and configuration using the ngx-matomo plugin.
Now, when a user visites my webpage, the Angular configuration requests the matomo script from the same website under s.js and sends all the data to s.php. For the user it all apears to be coming from the same domain