Service: Matomo - EyevinnOSC/community GitHub Wiki

Matomo

Matomo (serviceId matomo-org-matomo) is an open-source web analytics platform that gives you full ownership of your visitor data with no third-party data sharing. In Eyevinn Open Source Cloud (OSC) it is a long-running service instance with up to 10 GiB of storage per instance. License: GPL-3.0.

What it can do

  • Track website visits with a JavaScript tracking snippet, with dashboards, goals, funnels, heatmaps and event tracking.
  • Support GDPR-compliant data collection.
  • Provide a Reporting API and a Tracking API for programmatic access.
  • Store data in an external MySQL (8.0+) or MariaDB (10.6+) database for production use.

Creating an instance

All database options are optional.

Basic (evaluation): create Matomo without database details and it uses its own bundled storage.

{ "name": "mymatomo" }

Production with an external database:

  1. Create a MariaDB instance (serviceId: "linuxserver-docker-mariadb") with create-service-instance and wait until it is running. Example CLI call:
osc create linuxserver-docker-mariadb mymariadb \
  -o Password="{{secrets.mariadb-password}}" \
  -o Database="matomo"
  1. Create Matomo with the connection details (serviceId: "matomo-org-matomo"):
{
  "name": "mymatomo",
  "DatabaseHost": "<mariadb-host>",
  "DatabaseAdapter": "PDO_MYSQL",
  "DatabaseUsername": "<user>",
  "DatabasePassword": "{{secrets.mariadb-password}}",
  "DatabaseDbName": "matomo",
  "DatabaseTablesPrefix": "matomo_"
}

Get the address of each instance with describe-service-instance, and check state with get-instance-status.

Options

Option Required Type Meaning
name Yes string Name of the instance. Letters, digits and underscore only (^\w+$), at most 20 characters.
DatabaseHost No string Hostname (optionally host:port) of the MySQL/MariaDB server. Maps to MATOMO_DATABASE_HOST.
DatabaseAdapter No string PHP database adapter Matomo uses, for example PDO_MYSQL or MYSQLI.
DatabaseTablesPrefix No string Prefix prepended to all Matomo table names, so several installations can share a database. Example matomo_.
DatabaseUsername No string Database account username. Maps to MATOMO_DATABASE_USERNAME.
DatabasePassword No string, sensitive Database account password. Maps to MATOMO_DATABASE_PASSWORD.
DatabaseDbName No string Name of the database Matomo stores data in; it must already exist and be accessible by the user. Maps to MATOMO_DATABASE_DBNAME.

Store DatabasePassword as a service secret and pass it as {{secrets.NAME}} (whole field value only). Overwriting a secret does not restart a running instance.

Using the instance

Open the instance URL and follow the installation wizard: system check, database setup (enter your credentials or confirm auto-detection), create your first super user, add your first website. There are no pre-set default credentials; you create the admin account in the wizard.

Add the tracking snippet Matomo provides to the <head> of your site:

<!-- Matomo -->
<script>
  var _paq = window._paq = window._paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="https://<your-instance-url>/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->

Replace the URL with your instance URL and 1 with your site ID.

Query the Reporting API (find your token under Settings, Personal, Security, Auth Token):

curl "https://<your-instance-url>/index.php?module=API&method=VisitsSummary.get&idSite=1&period=day&date=last7&format=JSON&token_auth=<your-token>"

Limitations

  • Storage is limited to 10 GiB per instance.

Resources

⚠️ **GitHub.com Fallback** ⚠️