How to Install Matomo on Your Synology NAS

How to Install Matomo on Your Synology NAS

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.

💡Note: This guide works perfectly with the latest version of Matomo 5.0.2

  • 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.

Matomo Synology NAS Set up 11

  • STEP 5

Now click the “Create” button. Follow the instructions in the image below.

Matomo Synology NAS Set up 12

  • 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

Matomo Synology NAS Set up 13 new

  • 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.

Synology Proxy WebSocket

  • STEP 8

Go to Control Panel / Network / Connectivity tab/ Check Enable HTTP/2 then click Apply. Follow the instructions in the image below.

Matomo Synology NAS HTTP2

  • STEP 9

Go to Control Panel / Security / Advanced tab/ Check Enable HTTP Compression then click Apply. Follow the instructions in the image below.

Matomo Synology NAS HTTP Compression

  • 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.

1 Matomo Synology NAS Set up

  • 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.

1 Synology Portainer Add Stack

  • STEP 12

In the Name field type in matomo. Follow the instructions in the image below.

Note: Copy Paste the code below in the Portainer Stacks Web editor.

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.)

2-Matomo-Synology-NAS-Set-up-new-2026

  • 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.

3 Matomo Synology NAS Set up new 2024

  • STEP 14

If everything goes right, you will see this message at the top right of your screen: “Success Stack successfully deployed“.

4 Matomo Synology NAS Set up

  • 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.

Matomo Synology NAS Set up 16

  • STEP 17

Click NEXT. Follow the instructions in the image below.

Matomo Synology NAS Set up 17

  • STEP 18

  1. Database Server: type in mariadb
  2. Login: type in root
  3. Password: leave blank
  4. Database Name: type in matomodb

Click NEXT. Follow the instructions in the image below.

Matomo Synology NAS Set up 18

  • STEP 19

Click NEXT. Follow the instructions in the image below.

Matomo Synology NAS Set up 19

  • 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.

Matomo Synology NAS Set up 20

  • STEP 22

  1. Add your Website name
  2. Add your Website URL
  3. Select your Website time zone

Click NEXT. Follow the instructions in the image below.

Matomo Synology NAS Set up 21

  • STEP 23

Copy your own JavaScript Tracking Code into a .txt file (you will need it later). Follow the instructions in the image below.

Matomo Synology NAS Set up 22

  • STEP 24

Scroll down on the page until you see the NEXT button. Click on it. Follow the instructions in the image below.

Matomo Synology NAS Set up 23

  • STEP 25

Congratulations! Your Matomo installation is complete.

Matomo Synology NAS Set up 24

  • 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.

Matomo Synology NAS Set up 25

  • STEP 27

Sign in. Add the Username and Password you have previously created at STEP 21. Follow the instructions in the image below.

Matomo Synology NAS Set up 26

  • STEP 28

Welcome to your Matomo Analytics administrator dashboard!

Matomo Synology NAS Set up 27

  • 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.

Matomo Synology NAS Set up 28

  • 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.

Matomo Synology NAS Set up 29 new

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 Saturday / February 24th, 2024 at 8:06 PM