
You’ve decided to leave GA4. Maybe it’s GDPR concerns, maybe it’s the confusing interface, maybe it’s the fact that you don’t actually own your data. Whatever the reason, Matomo is the most popular destination — and for good reason. It’s the closest feature-equivalent to GA4 while giving you full data ownership.
But migration is scary. You have years of historical data in GA4, and you don’t want to start from zero. The good news: you don’t have to. I’ve migrated 15+ sites from GA4 to Matomo, and in this guide I’ll walk you through the exact process — including the gotchas that Matomo’s official docs don’t emphasize enough.
Before You Start: What You Can (and Can’t) Migrate
Let me be upfront about this, because I’ve seen too many people start the migration with unrealistic expectations:
| Data Type | Can Migrate? | Notes |
|---|---|---|
| Page views & sessions | Yes | Imported as aggregate data |
| Traffic sources & referrers | Yes | UTM parameters preserved |
| Goal conversions | Partial | GA4 “events” map to Matomo goals, but custom event parameters may not transfer cleanly |
| Custom dimensions | Yes | Auto-created during import |
| E-commerce transactions | Yes | Revenue, products, and order data import well |
| User-level data | No | GA4 user IDs and segments don’t transfer |
| Real-time & raw event streams | No | Only aggregated historical data is imported |
| Explorations & custom reports | No | You’ll rebuild these in Matomo (often easier) |
The honest truth: the import gives you historical trends and benchmarks. It won’t give you a perfect 1:1 replica of GA4. But for most sites, that’s exactly what you need — continuity for reporting, not raw event logs.
Step 1: Choose Your Matomo Setup

Before importing anything, decide how you’ll run Matomo:
| Option | Cost | Best For | Import Speed |
|---|---|---|---|
| Matomo Cloud | From $23/month | Non-technical teams, quick start | Fast (managed infrastructure) |
| Self-hosted (VPS) | $10-50/month (server) | Full control, GDPR data residency | Depends on server specs |
| Self-hosted (Docker) | Same as VPS | DevOps teams, easy upgrades | Depends on server specs |
For most of my clients, I recommend Matomo Cloud for the initial migration. You can always move to self-hosted later — Matomo lets you export everything. Starting with Cloud means you don’t have to debug server issues while figuring out the data import.
If you go self-hosted, use at least a 2-core VPS with 4GB RAM. The GA import is CPU-intensive, and a $5 VPS will choke on large datasets. I learned this the hard way when a client’s import ran for 11 days on a 1GB VPS before I killed it and moved to a beefier server.
Step 2: Set Up Google OAuth Credentials
Matomo connects to GA4 via the Google Analytics Data API. You’ll need to create OAuth credentials in the Google Cloud Console:
- Go to Google Cloud Console > APIs & Services > Credentials
- Create an OAuth 2.0 Client ID (Web application type)
- Add the authorized redirect URI:
https://your-matomo-domain/index.php?module=GoogleAnalyticsImporter&action=processAuthCode - Enable the Google Analytics Data API and Google Analytics Admin API in your project
- Copy the Client ID and Client Secret
Pro tip: If you’re importing multiple sites, use the “Advanced” OAuth configuration in Matomo instead of “Quick Connect.” Quick Connect uses Matomo’s shared OAuth app, which has lower API rate limits. Your own credentials give you 10x the throughput.
Step 3: Run the Import (Before Adding Tracking)

This is the most important timing detail, and it’s easy to miss:
Run the GA4 import BEFORE you add Matomo tracking to your site. The import creates a new site in Matomo. You cannot import into a site that already has tracking data — the data can’t be merged.
Here’s the process:
- In Matomo, go to Administration > Import > Google Analytics
- Enter your OAuth credentials and authorize access
- Select your GA4 property
- Set the end date to today (or the day you plan to add Matomo tracking)
- Start the import
How long does it take? Depends on your data volume:
| Monthly Page Views | History Length | Estimated Time |
|---|---|---|
| Under 50K | 2 years | 2-6 hours |
| 50K-500K | 2 years | 12-48 hours |
| 500K-5M | 2 years | 2-7 days |
| 5M+ | 2 years | 1-3 weeks |
The import runs as a background job. You can close the browser — it’ll keep going. Check progress anytime in the Import section. I tell clients to start the import on a Friday evening and check Monday morning.
Step 4: Add Matomo Tracking Code
Once the import finishes (or reaches today’s date), add the Matomo tracking code to your site. For WordPress, the cleanest method is a simple snippet in your theme’s <head>:
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://your-matomo-domain/";
_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 -->
For GDPR compliance without consent banners, add these two lines before trackPageView:
_paq.push(['disableCookies']);
_paq.push(['setDoNotTrack', true]);
This disables cookies entirely, making Matomo work like Plausible or Fathom — no consent banner needed. You lose some features (returning visitor identification, multi-session funnels) but gain full compliance. Most sites I migrate find this an acceptable trade-off.
Step 5: Recreate Your Goals and Events

The import brings over basic goal data, but GA4 events don’t always map cleanly to Matomo. Here’s what to do:
For simple page-based goals (e.g., thank-you page visits): create a Goal in Matomo under Administration > Goals. Set the pattern to “URL contains /thank-you/”. These work identically to GA4.
For event-based goals (e.g., button clicks, form submissions): use Matomo Tag Manager or JavaScript tracking:
// Track a custom event
_paq.push(['trackEvent', 'Conversion', 'Form Submit', 'Contact Form']);
// Track a goal manually
_paq.push(['trackGoal', 1]); // Goal ID 1
For e-commerce tracking: Matomo has built-in e-commerce analytics. On your order confirmation page:
_paq.push(['addEcommerceItem',
'SKU123', // Product SKU
'Product Name', // Product name
'Category', // Category
29.99, // Price
1 // Quantity
]);
_paq.push(['trackEcommerceOrder',
'ORDER-456', // Order ID
29.99, // Grand total
25.00, // Sub total
4.99, // Tax
0, // Shipping
false // Discount
]);
Step 6: Verify and Remove GA4

Run both GA4 and Matomo in parallel for 2-4 weeks. Compare:
- Total visitors — should be within 5-10% (Matomo typically reports slightly higher because it’s not blocked by ad blockers as often)
- Traffic sources — UTM-tagged traffic should match closely
- Goal conversions — verify your key conversion events are firing
- Page views per page — spot-check your top 10 pages
When I migrated a B2B SaaS site, Matomo showed 8% more visitors than GA4. The reason? GA4 was being blocked by Firefox’s Enhanced Tracking Protection and several ad blockers. Matomo on a first-party domain (analytics.theirdomain.com) wasn’t blocked. They’d been underreporting traffic for two years.
Once you’re confident in the data:
- Back up your Matomo database (the imported data is only in Matomo — if it’s deleted, you’d need to re-import)
- Remove the GA4 tracking code from your site
- Keep your GA4 property active for 6 months (you might need to reference old data)
- Update your privacy policy — remove Google Analytics mention, add Matomo
Common Migration Pitfalls

After 15+ migrations, these are the mistakes I see repeatedly:
- Adding tracking before the import finishes. This creates a separate site in Matomo with a data gap. Always import first, track second.
- Not setting an import end date. Without an end date, Matomo runs a “rolling import” that continuously pulls from GA4. This sounds useful but creates duplicate data once your Matomo tracking goes live. Set the end date to your go-live day.
- Undersized server for self-hosted. The import is CPU-heavy. A $5 VPS will work for tracking, but the import needs at least 4GB RAM. Scale up temporarily, then scale back down.
- Forgetting to re-process imported data. After a large import, run
./console core:archiveto generate reports. Without this, your historical dashboards may look empty. - Expecting exact data match. GA4 and Matomo count sessions differently. A 5-15% variance is normal and expected. Don’t spend days trying to make the numbers identical.
FAQ
How long should I keep GA4 running alongside Matomo?
Run both tools in parallel for 2-4 weeks after adding Matomo tracking. This gives you enough data to verify conversion tracking and spot any discrepancies. After that, remove the GA4 code. Keep the GA4 property itself for at least 6 months in case you need to reference historical reports.
Can I import Universal Analytics data into Matomo, or just GA4?
Matomo supports importing from both Universal Analytics and GA4. If you still have UA data in your Google account, import it now — Google has been gradually restricting access to historical UA data. The import process is nearly identical for both versions.
Will my Matomo data match GA4 exactly after import?
No, and that’s expected. GA4 and Matomo use different session definitions, attribution models, and bot filtering. Expect a 5-15% variance in most metrics. The imported data is best used for trend analysis and year-over-year comparisons, not exact number matching.
Do I need a consent banner for Matomo?
Not if you configure Matomo with cookies disabled. Self-hosted Matomo with cookieless tracking has been approved by the French DPA (CNIL) for use without consent. Add _paq.push(['disableCookies']) to your tracking code and you’re covered in most EU jurisdictions.
Migrating from GA4 to Matomo isn’t painless, but it’s straightforward if you follow the right sequence: import first, track second, verify with parallel running, then cut over. The result is analytics you own, hosted where you choose, with optional GDPR compliance that doesn’t require a cookie banner.
If you’re still deciding between Matomo and other options, check our Matomo vs Plausible comparison or browse the best GA4 alternatives for GDPR compliance.
