Matomo is a free and open source web analytics application developed by a team of international developers that runs on a PHP/MySQL webserver. It tracks online visits to one or more websites and displays reports on these visits for analysis. It’s very similar to Google Analytics, but you can host it on your Synology NAS. In this step by step guide I will show you how to install Matomo on your Synology NAS using Docker. Note: You can also use Umami or Plausible on your Synology NAS as alternative to Matomo.
STEP 1
Please Support My work by Making a Donation.
STEP 2
Install Portainer using my step by step guide. If you already have Portainer installed on your Synology NAS, skip this STEP. Attention: Make sure you have installed the latest Portainer version.
STEP 3
Make sure you have a synology.me Wildcard Certificate. Follow my guide to get a Wildcard Certificate. If you already have a synology.me Wildcard certificate, skip this STEP.
STEP 4
Go to Control Panel / Login Portal / Advanced Tab / click Reverse Proxy. Follow the instructions in the image below.
STEP 5
Now click the “Create” button. Follow the instructions in the image below.
STEP 6
After you click the Create button, the window below will open. Follow the instructions in the image below.
On the General area, set the Reverse Proxy Name description: type in matomo. After that, add the following instructions:
Source:
Protocol: HTTPS
Hostname: matomo.yourname.synology.me
Port: 443
Check Enable HSTS
Destination:
Protocol: HTTP
Hostname: localhost
Port: 8597
STEP 7
On the Reverse Proxy Rules click the Custom Header tab. Click Create and then, from the drop-down menu, click WebSocket. After you click on WebSocket, two Header Names and two Values will be automatically added. Click Save. Follow the instructions in the image below.
STEP 8
Go to Control Panel / Network / Connectivity tab/ Check Enable HTTP/2 then click Apply. Follow the instructions in the image below.
STEP 9
Go to Control Panel / Security / Advanced tab/ Check Enable HTTP Compression then click Apply. Follow the instructions in the image below.
STEP 10
Go to File Station and open the docker folder. Inside the docker folder, create two new folders and them matomo and matomodb. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.
STEP 11
Log into Portainer using your username and password. On the left sidebar in Portainer, click on Stacks then + Add stack. Follow the instructions in the image below.
STEP 12
In the Name field type in matomo. Follow the instructions in the image below.
version: '3.9' services: mariadb: container_name: Matomo-DB image: mariadb:11.3-jammy command: --max_allowed_packet=1073741824 restart: on-failure:5 volumes: - /volume1/docker/matomodb:/var/lib/mysql:rw environment: - MYSQL_ALLOW_EMPTY_PASSWORD=yes - MYSQL_DATABASE=matomodb matomo: container_name: Matomo environment: - PUID=1026 - PGID=100 - TZ=Europe/Bucharest ports: - 8597:80 depends_on: - mariadb volumes: - /volume1/docker/matomo:/var/www/html:rw image: matomo restart: on-failure:5
Note: After you paste the code in the Web editor, change the value numbers for PUID and PGID with your own values. (Follow my step by step guide on how to do this.)
Note: After you paste the code in the Web editor, change the value for TZ. (Select your current Time Zone from this list.)
STEP 13
Scroll down on the page until you see a button called Deploy the stack. Click on it. Follow the instructions in the image below. The installation process can take up to a few minutes. It will depend on your Internet speed connection.
STEP 14
If everything goes right, you will see this message at the top right of your screen: “Success Stack successfully deployed“.
STEP 15
Go back to STEP 1 or you will deal with karma 🙂
STEP 16
Now open your browser and type in your HTTPS/SSL certificate like this https://matomo.yourname.synology.me In my case it’s https://matomo.mariushosting.synology.me If everything goes right, you will see the Matomo installation page. Click NEXT. Follow the instructions in the image below.
STEP 17
Click NEXT. Follow the instructions in the image below.
STEP 18
- Database Server: type in mariadb
- Login: type in root
- Password: leave blank
- Database Name: type in matomodb
Click NEXT. Follow the instructions in the image below.
STEP 19
Click NEXT. Follow the instructions in the image below.
STEP 20
Go back to STEP 1 or you will deal with karma 🙂
STEP 21
Add a Username, a Password and your Email address for your matomo, then click NEXT. Follow the instructions in the image below.
STEP 22
- Add your Website name
- Add your Website URL
- Select your Website time zone
Click NEXT. Follow the instructions in the image below.
STEP 23
Copy your own JavaScript Tracking Code into a .txt file (you will need it later). Follow the instructions in the image below.
STEP 24
Scroll down on the page until you see the NEXT button. Click on it. Follow the instructions in the image below.
STEP 25
Congratulations! Your Matomo installation is complete.
STEP 26
Scroll down on the page until you see the CONTINUE TO MATOMO button. Click on it. Follow the instructions in the image below.
STEP 27
Sign in. Add the Username and Password you have previously created at STEP 21. Follow the instructions in the image below.
STEP 28
Welcome to your Matomo Analytics administrator dashboard!
STEP 29
Paste your personal Matomo JavaScript Tracking code you have automatically generated at STEP 23 on your website between the <head> and </head> tags of your site, then update your file. For example, I have a WordPress website hosted on a Synology NAS. If you have a WordPress website hosted elsewhere, know that the process is the same. Log into your WordPress admin Dashboard, click on the left sidebar on “Theme Editor”, select your theme then search for the header.php file. Paste your personal Matomo JavaScript Tracking code you have automatically generated at STEP 28 in the header.php file between the <head> and </head> tags of your site, then update your file. Follow the instructions in the image below.
Note: Paste the code in the website you have chosen at STEP 22. You can add multiple websites via the Matomo Dashboard later.
STEP 30
After the JavaScript code is added to your website, Matomo will start to collect Real-Time analytics of your website. My blog doesn’t have any TRACKING CODE on it. I just installed Matomo to show you how it works and how easily you can implement it on your website. I have already uninstalled it. Don’t forget to go back to STEP 1. I have worked hard for this guide so you can enjoy it.
Note: Can I run Docker on my Synology NAS? See the supported models.
Note: How to Back Up Docker Containers on your Synology NAS.
Note: Find out how to update the Matomo container with the latest image.
Note: How to Free Disk Space on Your NAS if You Run Docker.
Note: Instead of the synology.me DDNS you can also use your own domain name.
Note: How to Schedule Start & Stop For Docker Containers.
Note: How to Activate Email Notifications.
Note: How to Add Access Control Profile on Your NAS.
Note: How to Change Docker Containers Restart Policy.
Note: How to Use Docker Containers With VPN.
Note: Convert Docker Run Into Docker Compose.
Note: How to Clean Docker.
Note: How to Clean Docker Automatically.
Note: Best Practices When Using Docker and DDNS.
Note: Some Docker Containers Need WebSocket.
Note: Find out the Best NAS Models For Docker.
Note: Activate Gmail SMTP For Docker Containers.
This post was updated on Friday / August 23rd, 2024 at 3:26 PM