Matomo Self-Hosted Analytics
What Self-Hosting Actually Buys You
Matomo (formerly Piwik) is a full open-source web analytics platform you can run on your own servers, meaning every raw hit lands in a MySQL or MariaDB database you control, with no third-party processor relationship, no data leaving your infrastructure, and no vendor able to change terms, pricing, or data retention policy out from under you. This matters most for organizations under strict data residency mandates (public sector, healthcare, EU entities wary of international transfer rulings) or those who simply want permanent, unthrottled access to raw log-level data without an API quota.
Infrastructure Requirements and Scaling Reality
A self-hosted Matomo instance needs a web server (Apache/Nginx), PHP, and a MySQL-compatible database, and the archiving process (Matomo's term for the batch job that pre-aggregates raw visit logs into report-ready tables) is the component that scales poorly by default. At low-to-moderate traffic, the built-in cron-based archiving handles it fine. At higher traffic (millions of monthly pageviews), the raw log_visit and log_link_visit_action tables grow quickly, and without tuning the archiving process becomes slow enough to make 'today's' report data stale for hours. Running archiving on a dedicated schedule via console core:archive, moving to a MariaDB-compatible high-performance configuration, and periodically purging old raw logs (while keeping aggregated reports) are standard operational necessities, not optional extras.
# Recommended: run archiving via CLI on a schedule rather than
# relying on the browser-triggered archiving (which blocks page loads
# for whichever user happens to open a report first).
*/15 * * * * www-data php /var/www/matomo/console core:archive \
--url=https://analytics.yourcompany.com/ \
>> /var/log/matomo-archive.log 2>&1
# Periodically purge old raw log data once it's been archived,
# keeping only the aggregated report tables for older periods.
# Configured via Administration > Privacy > Delete old visitor logs.Self-Hosting Means You Own Security, Not Just Uptime
Feature Parity With GA4 — Where It Matches and Where It Doesn't
Matomo supports goal tracking, ecommerce tracking, custom dimensions, funnels (as a premium plugin), heatmaps and session recording (also premium plugins), and a tag-manager module comparable in spirit to GTM. Where it diverges most from GA4: Matomo retained a first-class session concept rather than GA4's pure event model, meaning reports like bounce rate and pages-per-visit behave the way analysts who grew up on Universal Analytics expect. It does not have GA4's BigQuery-native export pipeline — getting Matomo data into a warehouse means querying its own MySQL schema directly or using the Reporting API to export periodically.
-- Example: querying Matomo's underlying schema directly for
-- pageviews by URL over a date range, bypassing the Reporting API.
-- Useful for warehouse ETL jobs when you want raw access rather
-- than API-paginated exports.
SELECT
a.name AS page_url,
COUNT(*) AS pageview_count
FROM matomo_log_link_visit_action lva
JOIN matomo_log_action a ON lva.idaction_url = a.idaction
WHERE lva.server_time BETWEEN '2026-09-01' AND '2026-09-30'
AND a.type = 1 -- type 1 = URL action
GROUP BY a.name
ORDER BY pageview_count DESC
LIMIT 100;Matomo Cloud as the Middle Ground
If the operational burden of self-hosting is the blocker but data residency still matters, Matomo Cloud offers managed hosting with EU-based data centers — you lose the zero-third-party-processor benefit (Matomo the company does process your data) but keep EU data residency and shed the server maintenance, patching, and archiving-tuning work entirely. This is a reasonable compromise for teams that want Matomo's session-based model and privacy posture without running infrastructure.
Consent and Cookie Behavior Are Configurable, Not Automatic
What's Next?
Matomo is one piece of a broader open-source analytics ecosystem — pairing it with open-source event collection and warehousing tools can build a fully self-owned analytics stack worth evaluating as a complete architecture.
I build these systems professionally.
Whether it's a RAG pipeline, analytics migration, or AI workflow — let's talk.