Skip to content

← Atlas

Migrate from Google Analytics 4 to Matomo: Step-by-Step Guide

The full playbook for switching from GA4 to Matomo — including e-commerce schema rewrite, audience strategy, and reconciliation methods.

Why migrate

Matomo (formerly Piwik) is the most feature-complete privacy-first analytics platform. If your team relies on GA4’s depth — e-commerce funnels, custom segments, multi-channel reports — Matomo is the only viable destination among the privacy-first alternatives. Plausible and Fathom are deliberately simpler.

The cost is operational: Matomo Cloud starts at €19/mo but climbs fast with traffic. Self-hosted Matomo needs a real server (PHP, MySQL, ~2GB RAM, ongoing patching). Either way, expect more dev hours than a Plausible move.

Pre-migration checklist

  1. Decide deployment. Matomo Cloud (managed, EU-hosted) vs self-host (full control, full ops burden). Self-host needs MySQL 5.7+, PHP 8.0+, regular plugin updates.
  2. Inventory GA4 events, dimensions, goals, audiences. Matomo can replicate ~95% of GA4’s data model. Plan the mapping per dimension.
  3. Plan e-commerce. Matomo has native cart/checkout/refund tracking via _paq.push ecommerce calls. Different API from GA4 enhanced ecommerce — rewrite required.
  4. Decide retention. Matomo defaults to indefinite. Set a retention period (e.g. 26 months) before launch to stay compliant.
  5. GeoIP. Matomo needs MaxMind DB for accurate country reporting. Cloud handles this; self-host needs the DB installed.

Step-by-step

1. Audit (Days 1–4)

Export the GA4 event list, custom dimensions, goals, and audiences. Matomo doesn’t have audiences in the same sense — they’re called “Segments” and they’re query-time, not pre-computed. Plan to translate audiences into segment definitions.

2. Map (Days 4–8)

Each GA4 event → Matomo trackEvent or trackEcommerceOrder call. Custom dimensions map cleanly (Matomo also calls them “Custom Dimensions” — same nomenclature, different scoping rules).

js GA4 → Matomo: purchase event
<br />
gtag(‘event’, ‘purchase’, {<br />
  transaction_id: ‘T_12345’,<br />
  value: 99.00,<br />
  currency: ‘EUR’<br />
});</p>
<p>// Matomo equivalent<br />
_paq.push([‘trackEcommerceOrder’,<br />
  ‘T_12345’,  // order ID<br />
  99.00,      // grand total<br />
  null, null, null,<br />
  ‘EUR’<br />
]);<br />

3. Install Matomo (Days 8–10)

Either provision Matomo Cloud (10 minutes) or deploy self-hosted. For self-host: composer create-project matomo/matomo, configure DB, run installer, generate site_id.

html Matomo tracking code
<br />
<script>
  var _paq = window._paq = window._paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u = "https://stats.example.com/";
    _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><br />

4. Dual-tag (Days 10–35)

Run both for 30 days minimum. Matomo’s session definition is closer to GA4’s than Plausible’s, so expect smaller deltas — typically 5–15%. Validate with the Parallel-Run Validator daily.

5. Cutover (Day 36)

Remove GA4 snippet. Update internal dashboards (Looker Studio → Matomo Reporting API). Notify the team that report URLs are changing.

6. Verify (Days 37–60)

Compare 30-day metrics: visitors, page-views, conversion rate, e-commerce revenue, top channels. Document any unexplained deltas in a brief memo.

Common gotchas

  • E-commerce schema is rigid. Matomo doesn’t accept arbitrary item arrays the way GA4 does. Restructure your data layer.
  • Reporting API rate limits. Heavy dashboards can hit limits — cache aggressively in Looker Studio.
  • Self-host backup. Matomo’s archive tables grow fast. Daily MySQL backup + monthly archive purge required.
  • Plugin compatibility. Premium plugins (Heatmaps, Form Analytics) cost extra and aren’t all updated for the latest Matomo. Check before promising features.

Frequently asked

Cloud vs self-host — which is right?

Cloud if you have <500k pageviews/mo and don't want ops burden. Self-host if you have data residency requirements, EU compliance ambition, or >2M pageviews/mo (cloud pricing climbs fast).

Will Looker Studio work with Matomo?

Yes, via the Matomo Reporting API and a community connector. Performance is slower than GA4’s native connector — cache aggressively.

Can Matomo replace GA4 audiences for ad platforms?

Not directly. Matomo segments live in Matomo. For ad platform audiences, run server-side CAPI / Google Ads server-side from your backend, decoupled from analytics.

What's the LCP impact of Matomo's tracker?

Matomo’s matomo.js is ~25KB gzipped — heavier than Plausible (~1KB) but lighter than GA4 (~80KB). Async loading recommended.

How do I import historical GA4 data?

There’s no clean import path. Matomo has a Log Analytics CLI tool that ingests Apache/nginx access logs — useful for backfilling pageview history from raw server logs. Event-level history is not migratable.