<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Gdpr – Serverküche</title><link>https://serverkueche.de/en/tags/gdpr/</link><description>Gdpr – Neueste Beiträge von Serverküche</description><generator>Hugo</generator><language>en-US</language><managingEditor>feedback@serverkueche.de (Serverküche)</managingEditor><webMaster>feedback@serverkueche.de (Serverküche)</webMaster><copyright>2026 Serverküche</copyright><lastBuildDate>Tue, 04 Aug 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://serverkueche.de/en/tags/gdpr/index.xml" rel="self" type="application/rss+xml"/><item><title>Self-hosting Matomo cookieless: analytics without a consent banner</title><link>https://serverkueche.de/en/tutorials/self-host-matomo/</link><pubDate>Tue, 04 Aug 2026 00:00:00 +0000</pubDate><author>feedback@serverkueche.de (Serverküche)</author><guid>https://serverkueche.de/en/tutorials/self-host-matomo/</guid><description>Set up Matomo 5.12 with Docker &amp; Traefik: privacy-friendly web analytics with IP anonymization, entirely without Google and without a cookie banner.</description><content:encoded><![CDATA[<p>Google Analytics knows every one of your visitors better than you do yourself – and sends the data to the US. With Matomo you bring web analytics back onto your own server: GDPR-compliant, IP-anonymized and, in many cases, entirely without a cookie banner.</p>
<h2 id="what-are-we-building">What are we building?</h2>
<p>By the end, <strong>Matomo 5.12</strong> runs in Docker behind your Traefik reverse proxy, reachable under your own (sub)domain with a valid HTTPS certificate. As the database, <strong>MariaDB 11.4</strong> comes along – both in one <code>compose.yaml</code>. You get a full-featured analytics dashboard that evaluates visitor numbers, origin, devices and popular pages – the data lives exclusively on your server.</p>
<p>The real gain over Google Analytics is privacy: we take control of IP anonymization and configure Matomo so it works without cookies. That&rsquo;s the technical basis for being able, in many cases, to do without an annoying consent banner. Matomo is the full package – if all you want to know is which pages get how many hits, the much leaner <a href="/en/tutorials/self-host-hitkeep-analytics/">HitKeep</a> will do as well.</p>
<div class="not-prose my-6 rounded-lg border-l-4 p-4 border-sky-300 bg-sky-50 dark:border-sky-800 dark:bg-sky-900/20">
  <p class="mb-1 flex items-center gap-2 font-semibold text-slate-900 dark:text-white">
    <span aria-hidden="true">ℹ️</span>Note
  </p>
  <div class="prose-kitchen text-sm">This tutorial is no substitute for legal advice. Whether you specifically need a cookie banner depends on your use. But the configuration shown here (no cookies, IP anonymization, an opt-out option) is exactly the one Matomo and many data protection authorities name as the basis for consent-free operation.</div>
</div>
<h2 id="prerequisites">Prerequisites</h2>
<ul>
<li>A <a href="/en/tutorials/harden-ssh/">hardened server</a> with Debian 13 and a sudo user</li>
<li><a href="/en/tutorials/install-docker/">Docker &amp; Docker Compose installed</a></li>
<li>A <a href="/en/tutorials/traefik-reverse-proxy/">running Traefik reverse proxy</a> with the external network <code>proxy</code> and the certificate resolver <code>le</code> – Matomo hooks in there</li>
<li>A (sub)domain whose A/AAAA record <a href="/en/tutorials/connect-domain-to-server/">points to your server</a>, e.g. <code>stats.YOUR_DOMAIN</code></li>
<li>A <a href="/en/tutorials/restic-backups/">working backup strategy with Restic</a> – analytics data accumulates over years, you don&rsquo;t want to lose it</li>
</ul>
<p>Matomo is frugal: for a small to medium website, the VPS 1000 is plenty. Only with very high traffic or when many other services run alongside is it worth looking at more RAM – our <a href="/en/server-calculator/">server calculator</a> helps with the assessment.</p>
<div class="not-prose my-6 overflow-hidden rounded-xl border border-paprika-200 bg-paprika-50 dark:border-paprika-800 dark:bg-paprika-900/20"
     data-track-content data-content-name="Affiliate-Box · /en/tutorials/self-host-matomo/" data-content-piece="VPS 1000 G12">
  <div class="flex items-center justify-between border-b border-paprika-200 bg-paprika-100 px-4 py-1.5 text-xs font-semibold uppercase tracking-wide text-paprika-700 dark:border-paprika-800 dark:bg-paprika-900/40 dark:text-paprika-300">
    <span>🍳 Recommendation</span>
    <span title="Links marked with * are affiliate links.">Ad</span>
  </div>
  <div class="flex flex-col gap-4 p-4 sm:flex-row sm:items-center sm:justify-between">
    <div>
      <p class="text-lg font-bold text-slate-900 dark:text-white">VPS 1000 G12</p>
      <p class="mt-1 text-sm text-slate-600 dark:text-slate-300">4 vCores · 8 GB RAM · 256 GB NVMe</p>
      <p class="mt-1 text-sm font-semibold text-paprika-700 dark:text-paprika-400">from €10.36/month</p>
      <p class="mt-2 text-sm text-slate-600 dark:text-slate-400">Enough for Matomo alongside a few other small services.</p>
    </div>
    <a href="https://www.netcup.com/en/server/vps/vps-1000-g12-iv-12m?ref=44083" rel="sponsored noopener" target="_blank"
   data-track-event="Affiliate|netcup: Affiliate-Box|VPS 1000 G12 · {page}"
   class="inline-flex shrink-0 items-center justify-center rounded-lg bg-paprika-600 px-5 py-2.5 font-semibold text-white transition-colors hover:bg-paprika-700">
  Go to netcup →
</a>

  </div><div class="px-4 pb-4"><p class="not-prose my-3 flex flex-wrap items-center gap-x-2 gap-y-1 rounded-lg border border-herb-500/40 bg-herb-50 px-3 py-2 text-sm text-slate-700 dark:bg-herb-900/20 dark:text-slate-200">
  <span>💶 <strong>5 € voucher</strong> for new netcup customers:</span><code data-track-voucher="36nc17844976032"
        class="rounded bg-white px-2 py-0.5 font-mono text-sm font-semibold text-herb-800 dark:bg-slate-800 dark:text-herb-400">36nc17844976032</code>
  <span class="text-xs text-slate-500 dark:text-slate-400">(new customers only, no domains)</span>
</p></div>
</div>

<h2 id="step-by-step">Step by step</h2>
<h3 id="step-1-create-the-project-folder-and-check-the-network">Step 1: Create the project folder and check the network</h3>
<p>We create a dedicated folder for Matomo under <code>/opt</code> – this keeps every service cleanly separated:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">mkdir -p /opt/matomo <span class="o">&amp;&amp;</span> <span class="nb">cd</span> /opt/matomo</span></span></code></pre></div>
</div>
<p>Matomo has to go into the same Docker network as Traefik so the proxy can reach the container. Check that the <code>proxy</code> network from the <a href="/en/tutorials/traefik-reverse-proxy/">Traefik tutorial</a> exists:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">docker network ls <span class="p">|</span> grep proxy</span></span></code></pre></div>
</div>
<p>You should see a line with <code>proxy</code>. If not, set up Traefik first – without the proxy, Matomo won&rsquo;t get a certificate.</p>
<h3 id="step-2-move-passwords-into-a-env">Step 2: Move passwords into a <code>.env</code></h3>
<p>The database passwords do <strong>not</strong> belong in the <code>compose.yaml</code>, but in a separate <code>.env</code>. We have <code>openssl</code> generate them randomly:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="o">{</span>
</span></span><span class="line"><span class="cl">  <span class="nb">echo</span> <span class="s2">&#34;DB_PASSWORD=</span><span class="k">$(</span>openssl rand -hex 16<span class="k">)</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="nb">echo</span> <span class="s2">&#34;DB_ROOT_PASSWORD=</span><span class="k">$(</span>openssl rand -hex 16<span class="k">)</span><span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span> &gt; .env
</span></span><span class="line"><span class="cl">chmod <span class="m">600</span> .env</span></span></code></pre></div>
</div>
<p><code>chmod 600</code> ensures only <code>root</code> can read the file. Take a look inside once so you know the values:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">cat .env</span></span></code></pre></div>
</div>
<div class="sk-code">
  <span class="sk-code-head">Ausgabe</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">DB_PASSWORD=b51024e3f9a7c8d1e2f3a4b5c6d7e8f9
</span></span><span class="line"><span class="cl">DB_ROOT_PASSWORD=1a2b3c4d5e6f70819a0b1c2d3e4f5061</span></span></code></pre></div>
</div>
<h3 id="step-3-write-the-composeyaml">Step 3: Write the <code>compose.yaml</code></h3>
<p>Create the file <code>/opt/matomo/compose.yaml</code> with the following content. In the Traefik label, replace <strong><code>stats.YOUR_DOMAIN</code> with your real (sub)domain</strong>:</p>
<div class="sk-code">
  <span class="sk-code-head">YAML</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">services</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">db</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l">mariadb:11.4</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">container_name</span><span class="p">:</span><span class="w"> </span><span class="l">matomo-db</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">command</span><span class="p">:</span><span class="w"> </span>--<span class="l">max-allowed-packet=64MB</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">environment</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">MARIADB_DATABASE</span><span class="p">:</span><span class="w"> </span><span class="l">matomo</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">MARIADB_USER</span><span class="p">:</span><span class="w"> </span><span class="l">matomo</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">MARIADB_PASSWORD</span><span class="p">:</span><span class="w"> </span><span class="l">${DB_PASSWORD}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">MARIADB_ROOT_PASSWORD</span><span class="p">:</span><span class="w"> </span><span class="l">${DB_ROOT_PASSWORD}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">volumes</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="l">db:/var/lib/mysql</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">networks</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="l">intern]</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">restart</span><span class="p">:</span><span class="w"> </span><span class="l">unless-stopped</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">app</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">image</span><span class="p">:</span><span class="w"> </span><span class="l">matomo:5.12-apache</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">container_name</span><span class="p">:</span><span class="w"> </span><span class="l">matomo</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">environment</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">MATOMO_DATABASE_HOST</span><span class="p">:</span><span class="w"> </span><span class="l">db</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">MATOMO_DATABASE_ADAPTER</span><span class="p">:</span><span class="w"> </span><span class="l">mysql</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">MATOMO_DATABASE_USERNAME</span><span class="p">:</span><span class="w"> </span><span class="l">matomo</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">MATOMO_DATABASE_PASSWORD</span><span class="p">:</span><span class="w"> </span><span class="l">${DB_PASSWORD}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span><span class="nt">MATOMO_DATABASE_DBNAME</span><span class="p">:</span><span class="w"> </span><span class="l">matomo</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">volumes</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="l">app:/var/www/html</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">depends_on</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="l">db]</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">networks</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="l">proxy, intern]</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">restart</span><span class="p">:</span><span class="w"> </span><span class="l">unless-stopped</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">labels</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s2">&#34;traefik.enable=true&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s2">&#34;traefik.http.routers.matomo.rule=Host(`stats.YOUR_DOMAIN`)&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s2">&#34;traefik.http.routers.matomo.entrypoints=websecure&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s2">&#34;traefik.http.routers.matomo.tls.certresolver=le&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="s2">&#34;traefik.http.services.matomo.loadbalancer.server.port=80&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">networks</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">proxy</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">external</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">intern</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">external</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">volumes</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">db</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="l">app:</span></span></span></code></pre></div>
</div>
<p>The most important things about this file:</p>
<ul>
<li><strong>Two networks, deliberately separated.</strong> Only the <code>app</code> container is on the <code>proxy</code> network and thus reachable from outside. The database is on the internal <code>intern</code> network and is <strong>not</strong> addressable via Traefik – exactly right.</li>
<li><strong>The <code>MATOMO_DATABASE_*</code> variables</strong> pre-fill the web installer in the next step automatically. So you don&rsquo;t have to type the DB data again by hand.</li>
<li><strong><code>max-allowed-packet=64MB</code></strong> is recommended by Matomo for the database, otherwise the import of large reports can abort.</li>
<li><strong>No port to the outside.</strong> Neither Matomo nor the DB publishes a host port. The only way in leads via Traefik and thus via HTTPS.</li>
</ul>
<h3 id="step-4-start-the-stack">Step 4: Start the stack</h3>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">docker compose up -d</span></span></code></pre></div>
</div>
<p>On the first start, Docker downloads the images (about 310 MB of downloads, a good 1.3 GB unpacked) and creates the volumes. Then check the status:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">docker compose ps</span></span></code></pre></div>
</div>
<div class="sk-code">
  <span class="sk-code-head">Ausgabe</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">NAME        IMAGE                COMMAND                  SERVICE   CREATED          STATUS          PORTS
</span></span><span class="line"><span class="cl">matomo      matomo:5.12-apache   &#34;/entrypoint.sh apac…&#34;   app       15 seconds ago   Up 13 seconds   80/tcp
</span></span><span class="line"><span class="cl">matomo-db   mariadb:11.4         &#34;docker-entrypoint.s…&#34;   db        15 seconds ago   Up 14 seconds   3306/tcp</span></span></code></pre></div>
</div>
<p>Both containers should be <code>Up</code>. Traefik detects the new container automatically via the labels and fetches a Let&rsquo;s Encrypt certificate for your domain in the background. That usually takes only a few seconds. Check from your own machine whether Matomo responds:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">curl -sI https://stats.YOUR_DOMAIN <span class="p">|</span> head -1</span></span></code></pre></div>
</div>
<div class="sk-code">
  <span class="sk-code-head">Ausgabe</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">HTTP/2 200</span></span></code></pre></div>
</div>
<p>An <code>HTTP/2 200</code> means: the certificate is in place, Traefik routes, Matomo runs. If a certificate error comes instead, give Traefik a few more seconds – see &ldquo;When things go wrong&rdquo;.</p>
<div class="not-prose my-6 rounded-lg border-l-4 p-4 border-amber-400 bg-amber-50 dark:border-amber-700 dark:bg-amber-900/20">
  <p class="mb-1 flex items-center gap-2 font-semibold text-slate-900 dark:text-white">
    <span aria-hidden="true">⚠️</span>Finish the installer immediately
  </p>
  <div class="prose-kitchen text-sm">As soon as the stack runs, your Matomo URL is publicly reachable – and the web installer still open. Whoever comes first creates the admin account. So click through the installer (steps 5 and 6) <strong>right afterwards</strong>, instead of leaving the instance unfinished for days. If you can&rsquo;t do that immediately, protect the domain temporarily – e.g. via <a href="/en/tutorials/traefik-reverse-proxy/">Traefik basic auth</a> or an IP allowlist that only lets your own address through.</div>
</div>
<h3 id="step-5-click-through-the-web-installer">Step 5: Click through the web installer</h3>
<p>Open <code>https://stats.YOUR_DOMAIN</code> in the browser. Matomo greets you with an eight-step setup wizard.</p>
<p><figure class="my-6"><img src="/en/tutorials/self-host-matomo/matomo-installer_hu_53df1f3592e88e3.webp" srcset="/en/tutorials/self-host-matomo/matomo-installer_hu_dd01f90c0d952834.webp 480w, /en/tutorials/self-host-matomo/matomo-installer_hu_53df1f3592e88e3.webp 768w, /en/tutorials/self-host-matomo/matomo-installer_hu_9c2b274fe7e15c56.webp 1200w, /en/tutorials/self-host-matomo/matomo-installer_hu_286ad5dc793f6adc.webp 1920w" sizes="(min-width: 768px) 768px, 100vw"
    width="768" height="432"
    data-full="/en/tutorials/self-host-matomo/matomo-installer_hu_5198089e803ba170.webp"
    alt="Matomo installation wizard in the browser, welcome page with the step list from &ldquo;1. Welcome&rdquo; to &ldquo;8. Congratulations&rdquo;" title="The web installer of Matomo 5.12 – eight steps to the finished dashboard"
    loading="lazy" decoding="async" class="rounded-lg"><figcaption class="mt-2 text-sm text-center text-slate-500 italic">The web installer of Matomo 5.12 – eight steps to the finished dashboard</figcaption></figure></p>
<p>Click through the first steps:</p>
<ol>
<li><strong>Welcome</strong> → <em>Next</em>.</li>
<li><strong>System check</strong>: Matomo checks the PHP version, extensions and write permissions. Thanks to the official image, the list stays free of errors. You&rsquo;ll still see one yellow warning: <em>Forced SSL Connection</em>. It&rsquo;s normal here and no reason to stop – Matomo&rsquo;s own <code>force_ssl</code> option simply isn&rsquo;t set yet, while delivery is HTTPS-only anyway. We clear it in step 7. → <em>Next</em>.</li>
<li><strong>Set up the database</strong>: the fields are already filled in (the <code>MATOMO_DATABASE_*</code> variables from the <code>compose.yaml</code> do that). Briefly verify that the server is <code>db</code>, and click <em>Next</em>.</li>
<li><strong>Create tables</strong>: Matomo creates its database schema. → <em>Next</em>.</li>
</ol>
<p>Now you create your <strong>main administrator</strong>. Choose a username, a strong password and a real email address (security and update notices come through it).</p>
<p>Then you set up the <strong>first website</strong> you want to track. Besides name and URL, the <strong>website timezone</strong> is a required field: leave it on the placeholder and the form sends you back with <em>Website timezone is not valid</em>. It decides when a new day starts for your reports.</p>
<p><figure class="my-6"><img src="/en/tutorials/self-host-matomo/matomo-website_hu_b217dc7f93b2121f.webp" srcset="/en/tutorials/self-host-matomo/matomo-website_hu_e0fb0136b7af3d27.webp 480w, /en/tutorials/self-host-matomo/matomo-website_hu_b217dc7f93b2121f.webp 768w, /en/tutorials/self-host-matomo/matomo-website_hu_ea73a371a859144f.webp 1200w, /en/tutorials/self-host-matomo/matomo-website_hu_98760e0298847f1f.webp 1920w" sizes="(min-width: 768px) 768px, 100vw"
    width="768" height="432"
    data-full="/en/tutorials/self-host-matomo/matomo-website_hu_83c3f773e0a79fd1.webp"
    alt="The &ldquo;Set up a Website&rdquo; form in the Matomo installer with the fields for name, address and timezone of the website" title="Step 6: create the first website to track – the timezone is required"
    loading="lazy" decoding="async" class="rounded-lg"><figcaption class="mt-2 text-sm text-center text-slate-500 italic">Step 6: create the first website to track – the timezone is required</figcaption></figure></p>
<h3 id="step-6-add-the-tracking-code">Step 6: Add the tracking code</h3>
<p>In the second-to-last step, Matomo shows you the <strong>JavaScript tracking code</strong>. That&rsquo;s the small snippet that belongs on every page of your website – ideally right before <code>&lt;/head&gt;</code>:</p>
<p><figure class="my-6"><img src="/en/tutorials/self-host-matomo/matomo-tracking_hu_6626c761541fa35b.webp" srcset="/en/tutorials/self-host-matomo/matomo-tracking_hu_44f958d3f70d37fb.webp 480w, /en/tutorials/self-host-matomo/matomo-tracking_hu_6626c761541fa35b.webp 768w, /en/tutorials/self-host-matomo/matomo-tracking_hu_7d2f24dfbf211ffd.webp 1200w, /en/tutorials/self-host-matomo/matomo-tracking_hu_348cf6d3236b91d8.webp 1920w" sizes="(min-width: 768px) 768px, 100vw"
    width="768" height="432"
    data-full="/en/tutorials/self-host-matomo/matomo-tracking_hu_ae26394fbac73d0e.webp"
    alt="Matomo installer shows the finished JavaScript tracking code to copy" title="The tracking code – this snippet goes into the head area of your website"
    loading="lazy" decoding="async" class="rounded-lg"><figcaption class="mt-2 text-sm text-center text-slate-500 italic">The tracking code – this snippet goes into the head area of your website</figcaption></figure></p>
<div class="sk-code">
  <span class="sk-code-head">HTML</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-html" data-lang="html"><span class="line"><span class="cl"><span class="c">&lt;!-- Matomo --&gt;</span>
</span></span><span class="line"><span class="cl"><span class="p">&lt;</span><span class="nt">script</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl">  <span class="kd">var</span> <span class="nx">_paq</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">_paq</span> <span class="o">=</span> <span class="nb">window</span><span class="p">.</span><span class="nx">_paq</span> <span class="o">||</span> <span class="p">[];</span>
</span></span><span class="line"><span class="cl">  <span class="nx">_paq</span><span class="p">.</span><span class="nx">push</span><span class="p">([</span><span class="s1">&#39;disableCookies&#39;</span><span class="p">]);</span>
</span></span><span class="line"><span class="cl">  <span class="nx">_paq</span><span class="p">.</span><span class="nx">push</span><span class="p">([</span><span class="s1">&#39;trackPageView&#39;</span><span class="p">]);</span>
</span></span><span class="line"><span class="cl">  <span class="nx">_paq</span><span class="p">.</span><span class="nx">push</span><span class="p">([</span><span class="s1">&#39;enableLinkTracking&#39;</span><span class="p">]);</span>
</span></span><span class="line"><span class="cl">  <span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="kd">var</span> <span class="nx">u</span><span class="o">=</span><span class="s2">&#34;//stats.YOUR_DOMAIN/&#34;</span><span class="p">;</span>
</span></span><span class="line"><span class="cl">    <span class="nx">_paq</span><span class="p">.</span><span class="nx">push</span><span class="p">([</span><span class="s1">&#39;setTrackerUrl&#39;</span><span class="p">,</span> <span class="nx">u</span><span class="o">+</span><span class="s1">&#39;matomo.php&#39;</span><span class="p">]);</span>
</span></span><span class="line"><span class="cl">    <span class="nx">_paq</span><span class="p">.</span><span class="nx">push</span><span class="p">([</span><span class="s1">&#39;setSiteId&#39;</span><span class="p">,</span> <span class="s1">&#39;1&#39;</span><span class="p">]);</span>
</span></span><span class="line"><span class="cl">    <span class="kd">var</span> <span class="nx">d</span><span class="o">=</span><span class="nb">document</span><span class="p">,</span> <span class="nx">g</span><span class="o">=</span><span class="nx">d</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">&#39;script&#39;</span><span class="p">),</span> <span class="nx">s</span><span class="o">=</span><span class="nx">d</span><span class="p">.</span><span class="nx">getElementsByTagName</span><span class="p">(</span><span class="s1">&#39;script&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">];</span>
</span></span><span class="line"><span class="cl">    <span class="nx">g</span><span class="p">.</span><span class="kr">async</span><span class="o">=</span><span class="kc">true</span><span class="p">;</span> <span class="nx">g</span><span class="p">.</span><span class="nx">src</span><span class="o">=</span><span class="nx">u</span><span class="o">+</span><span class="s1">&#39;matomo.js&#39;</span><span class="p">;</span> <span class="nx">s</span><span class="p">.</span><span class="nx">parentNode</span><span class="p">.</span><span class="nx">insertBefore</span><span class="p">(</span><span class="nx">g</span><span class="p">,</span><span class="nx">s</span><span class="p">);</span>
</span></span><span class="line"><span class="cl">  <span class="p">})();</span>
</span></span><span class="line"><span class="cl"><span class="p">&lt;/</span><span class="nt">script</span><span class="p">&gt;</span>
</span></span><span class="line"><span class="cl"><span class="c">&lt;!-- End Matomo Code --&gt;</span></span></span></code></pre></div>
</div>
<p>We deliberately added the line <code>_paq.push(['disableCookies']);</code> (not included in the original snippet): with it, Matomo does entirely without cookies – an important building block for operation without a consent banner. If you run your website with a CMS like WordPress, there are ready-made plugins (&ldquo;Matomo for WordPress&rdquo;, &ldquo;Connect Matomo&rdquo;) that embed the snippet automatically. After the last step (&ldquo;Finish&rdquo;), you log in with the account you just created and land in the dashboard.</p>
<p><figure class="my-6"><img src="/en/tutorials/self-host-matomo/matomo-dashboard_hu_186f68b605b0e79e.webp" srcset="/en/tutorials/self-host-matomo/matomo-dashboard_hu_61bb4e60427f80e0.webp 480w, /en/tutorials/self-host-matomo/matomo-dashboard_hu_186f68b605b0e79e.webp 768w, /en/tutorials/self-host-matomo/matomo-dashboard_hu_8b5e93b8c4c64a5.webp 1200w, /en/tutorials/self-host-matomo/matomo-dashboard_hu_a91969f1d4a5d77c.webp 1920w" sizes="(min-width: 768px) 768px, 100vw"
    width="768" height="432"
    data-full="/en/tutorials/self-host-matomo/matomo-dashboard_hu_8044f97a992cc8d.webp"
    alt="Matomo dashboard after installation with the visitor overview and the administration menu" title="The finished Matomo dashboard – all data lives on your server"
    loading="lazy" decoding="async" class="rounded-lg"><figcaption class="mt-2 text-sm text-center text-slate-500 italic">The finished Matomo dashboard – all data lives on your server</figcaption></figure></p>
<p>The dashboard bundles the most important reports: <em>Visits in real-time</em>, <em>Visits Over Time</em>, the <em>Visits Overview</em>, a <em>Visitor Map</em> and, under <em>Channel Types</em>, the origin of visitors (search engine, direct, referral). Via the menu on the left you go deeper – <strong>Visitors</strong> (devices, browsers, location), <strong>Behaviour</strong> (pages, entries and exits) and <strong>Acquisition</strong> (which channels bring visitors). Exactly the questions Google Analytics answers – only on your server.</p>
<div class="not-prose my-6 rounded-lg border-l-4 p-4 border-amber-400 bg-amber-50 dark:border-amber-700 dark:bg-amber-900/20">
  <p class="mb-1 flex items-center gap-2 font-semibold text-slate-900 dark:text-white">
    <span aria-hidden="true">⚠️</span>Secure the admin account
  </p>
  <div class="prose-kitchen text-sm">Your Matomo account sees the complete visit behavior of your website – a worthwhile target. Assign a long, unique password and enable <strong>two-factor authentication</strong> under Administration → <em>Personal → Security</em> (the plugin is already on board). This way, even with a leaked password, no one gets at your data.</div>
</div>
<h3 id="step-7-check-the-privacy-settings-the-important-part">Step 7: Check the privacy settings (the important part)</h3>
<p>Matomo 5.12 starts out more privacy-friendly than many expect: IP anonymization is <strong>on by default</strong>. Still, walk through the page once – first, to have seen it with your own eyes, second, because there is a switch on it that really secures your cookieless tracking. Open <strong>Administration</strong> (gear) at the top right → <strong>Privacy → Anonymize data</strong> in the menu on the left.</p>
<p><figure class="my-6"><img src="/en/tutorials/self-host-matomo/matomo-datenschutz_hu_7af55f22679b3999.webp" srcset="/en/tutorials/self-host-matomo/matomo-datenschutz_hu_4f047bc4667cb237.webp 480w, /en/tutorials/self-host-matomo/matomo-datenschutz_hu_7af55f22679b3999.webp 768w, /en/tutorials/self-host-matomo/matomo-datenschutz_hu_c11282b3cd4b3695.webp 1200w, /en/tutorials/self-host-matomo/matomo-datenschutz_hu_b2aa088f929e7bf3.webp 1920w" sizes="(min-width: 768px) 768px, 100vw"
    width="768" height="432"
    data-full="/en/tutorials/self-host-matomo/matomo-datenschutz_hu_4910d6c342e09ec2.webp"
    alt="Matomo&rsquo;s &ldquo;Anonymize data&rdquo; page with IP anonymization enabled and the selection of masked bytes" title="Privacy → Anonymize data: IP anonymization is already set to two bytes"
    loading="lazy" decoding="async" class="rounded-lg"><figcaption class="mt-2 text-sm text-center text-slate-500 italic">Privacy → Anonymize data: IP anonymization is already set to two bytes</figcaption></figure></p>
<p>Three knobs are decisive:</p>
<ul>
<li><strong>Anonymize Visitors&rsquo; IP addresses</strong>: already set to <em>Yes</em>, and <strong>2 byte(s)</strong> are masked by default – <code>203.0.113.45</code> therefore becomes <code>203.0.xxx.xxx</code> (Matomo itself marks this level as <em>Recommended</em>). Just check that it stayed that way; with it the individual visitor is no longer identifiable.</li>
<li><strong>Force tracking without cookies</strong>: turn it on. Matomo then extends <code>matomo.js</code> with the matching code server-side and ignores tracking cookies on receipt as well. That still works if the original snippet without <code>disableCookies</code> ends up somewhere – a safety net for the very thing your consent-banner-free operation hangs on.</li>
<li><strong>&ldquo;Do Not Track&rdquo;</strong>: lives under <em>Privacy → Users opt-out</em>. Matomo now classifies the support as <strong>deprecated</strong> itself – because browsers send the signal unasked or have dropped support entirely, &ldquo;we no longer recommend enabling this option&rdquo;. So don&rsquo;t rely on it. The dependable route is on the same page: the <strong>opt-out building block</strong> (iframe or your own form) that you embed in your privacy policy.</li>
</ul>
<div class="not-prose my-6 rounded-lg border-l-4 p-4 border-herb-400 bg-herb-50 dark:border-herb-700 dark:bg-herb-900/20">
  <p class="mb-1 flex items-center gap-2 font-semibold text-slate-900 dark:text-white">
    <span aria-hidden="true">🧑‍🍳</span>Tip
  </p>
  <div class="prose-kitchen text-sm">Under <em>Privacy → Anonymize data → Regularly delete old raw data from the database</em> you can instruct Matomo to delete raw data automatically after e.g. 180 days. That reduces the data volume <strong>and</strong> the privacy risk – the aggregated reports are preserved.</div>
</div>
<p>That leaves the switch the system check from step 5 complained about: <code>force_ssl</code>. It makes Matomo itself reject unencrypted access instead of relying on Traefik alone. There is no setting for it in the interface; it lives in Matomo&rsquo;s <code>config/config.ini.php</code> inside the volume:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">cd</span> /opt/matomo
</span></span><span class="line"><span class="cl">docker compose <span class="nb">exec</span> -u www-data app sed -i <span class="s1">&#39;/^\[General\]/a force_ssl = 1&#39;</span> config/config.ini.php</span></span></code></pre></div>
</div>
<p><code>sed</code> appends the line <code>force_ssl = 1</code> right below the <code>[General]</code> section; <code>-u www-data</code> makes sure the file keeps its previous owner so Matomo can still write to it. Reload the dashboard afterwards – under <em>Administration → Diagnostic → System Check</em> the <em>Forced SSL Connection</em> warning is gone.</p>
<h3 id="step-8-archive-reports-via-cron">Step 8: Archive reports via cron</h3>
<p>By default, Matomo computes its reports &ldquo;on the fly&rdquo; as soon as someone opens the dashboard. That gets slow with more traffic and is officially not recommended. Better: a cron job computes the reports regularly in the background.</p>
<p>For that, on the host, enter a cron job that runs the archiving command in the container every 15 minutes:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">crontab -e</span></span></code></pre></div>
</div>
<p>Add this line (adjust the domain):</p>
<div class="sk-code">
  <span class="sk-code-head">Ausgabe</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">*/15 * * * * cd /opt/matomo &amp;&amp; docker compose exec -T -u www-data app ./console core:archive --url=https://stats.YOUR_DOMAIN &gt;&gt; /opt/matomo/archive.log 2&gt;&amp;1</span></span></code></pre></div>
</div>
<p>The log deliberately lands in <code>/opt/matomo/archive.log</code> and not under <code>/var/log</code>: if your cron runs as a sudo user (not as <code>root</code>), a write to <code>/var/log</code> fails silently. In <code>/opt/matomo</code> you have write permissions, and you find the log right by the project.</p>
<p>Then switch off the old mode: Administration → <em>General settings</em> → <em>Archiving settings</em>, set <strong>&ldquo;Archive reports when viewed from the browser&rdquo;</strong> to <strong>No</strong> and save. This keeps the dashboard fast even with a lot of traffic – and the system check stops reporting that browser and cron archiving run side by side.</p>
<h2 id="when-things-go-wrong">When things go wrong</h2>
<div class="troubleshoot not-prose">
<p><strong>The browser shows a certificate error or <code>404 page not found</code>.</strong> Traefik hasn&rsquo;t fetched the Let&rsquo;s
Encrypt certificate yet, or the DNS record doesn&rsquo;t point to the server. check with <code>dig stats.YOUR_DOMAIN</code> that the IP is correct, and look at the Traefik logs. You find the exact
container name from your Traefik setup with <code>docker ps | grep traefik</code>, then <code>docker logs &lt;container-name&gt;</code> (for us e.g. <code>docker logs traefik-traefik-1</code>). The HTTP challenge fails if port 80
isn&rsquo;t reachable from outside – check your <a href="/en/tutorials/firewall-ufw-setup/">firewall</a> and the
<a href="/en/tutorials/netcup-firewall-setup/">netcup firewall</a>.</p>
<p><strong>The installer reports <code>SQLSTATE... Connection refused</code> or hangs at the database.</strong> MariaDB wasn&rsquo;t
ready on the first start. give the DB a moment and reload the page. Check with <code>docker compose logs db</code> whether it says <code>ready for connections</code>. If an access error appears instead, the <code>DB_PASSWORD</code>
in the <code>.env</code> and the already-created DB no longer match – then a clean restart with <code>docker compose down -v</code> (careful: deletes the data) and <code>docker compose up -d</code> helps.</p>
<p><strong>Warning &ldquo;It looks like the <code>trusted_hosts</code> setting is not correct&rdquo;.</strong> Matomo checks, for security
reasons, under which hostname it&rsquo;s called. the warning appears when you change the domain. Confirm
the correct hostname via the button in the message – Matomo then enters it in
<code>config/config.ini.php</code>.</p>
<p><strong>No visits appear in the dashboard.</strong> the tracking code is missing, incorrectly embedded, or you&rsquo;re
visiting your own site (Matomo ignores you if your IP is excluded). open your website in a private
window and check in the network tab whether a request to <code>matomo.php</code> goes out. In Matomo,
<em>Administration → Diagnostic → Tracking failures</em> helps.</p>
<p><strong>The dashboard loads very slowly.</strong> the on-the-fly archiving computes on every call. set up the
archiving cron from step 8 and switch report generation to cron.</p>

</div>

<h2 id="maintenance--backups">Maintenance &amp; backups</h2>
<p><strong>Updates</strong> are uncritical with Matomo but due regularly – a new version appears about monthly. Because we pinned the image tag to <code>5.12</code>, you pull security patches within the 5.12 series like this:</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">cd</span> /opt/matomo <span class="o">&amp;&amp;</span> docker compose pull <span class="o">&amp;&amp;</span> docker compose up -d</span></span></code></pre></div>
</div>
<p>On the first call after an update, Matomo checks whether a <strong>database upgrade</strong> is needed and performs it after a click.</p>
<div class="not-prose my-6 rounded-lg border-l-4 p-4 border-amber-400 bg-amber-50 dark:border-amber-700 dark:bg-amber-900/20">
  <p class="mb-1 flex items-center gap-2 font-semibold text-slate-900 dark:text-white">
    <span aria-hidden="true">⚠️</span>Before a major upgrade: backup and release notes
  </p>
  <div class="prose-kitchen text-sm">For a jump to a new major version (e.g. 5.12 → 6.x), you raise the tag in the <code>compose.yaml</code>. A major upgrade often entails more extensive database migrations that can&rsquo;t easily be rolled back. So read the release notes first and <strong>definitely pull a backup</strong> (see below) before you start the new image.</div>
</div>
<p><strong>Backups</strong> comprise two things: the database (all visit data) and the <code>app</code> volume (your configuration in <code>config/config.ini.php</code>). Create a database dump regularly …</p>
<div class="sk-code">
  <span class="sk-code-head">Terminal</span>
  <div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">docker compose <span class="nb">exec</span> -T db sh -c <span class="s1">&#39;exec mariadb-dump -u matomo -p&#34;$MARIADB_PASSWORD&#34; matomo&#39;</span> &gt; /opt/matomo/dump.sql</span></span></code></pre></div>
</div>
<p>… and include this dump together with the <code>/opt/matomo</code> folder in your <a href="/en/tutorials/restic-backups/">Restic off-site backups</a>. A netcup snapshot of the whole server is a good complement, but <a href="/en/tutorials/netcup-snapshots-scp/">no substitute for a real off-site backup</a> – if both are at the same provider, both are gone in a total failure.</p>
<p><strong>Ongoing operation:</strong> keep an eye on disk space – with a lot of traffic the database grows. The automatic deletion of old raw data (step 7) and the archiving cron (step 8) keep Matomo lean and fast permanently. So you notice when Matomo is ever unreachable, add the instance to your <a href="/en/tutorials/uptime-kuma-monitoring/">Uptime Kuma monitoring</a> – a simple HTTP check on your stats domain is enough.</p>
<p>And the most important operational note to finish: Matomo lives off its privacy promise. Whoever has set the service up once should not soften the anonymization and deletion settings from step 7 again – they are the reason you can do without a consent banner in the first place. After every larger update, briefly check that they&rsquo;re still in place.</p>
]]></content:encoded></item></channel></rss>