Migrating from Google Analytics
Antlytics cannot import historical data from Google Analytics — GA4 does not export individual event records in a portable format. This guide explains how to run both tools in parallel, verify Antlytics is working correctly, and remove GA4 when you are ready.
Recommended approach: run Antlytics alongside GA4 for two to four weeks before removing GA4. This gives you a reference period to compare numbers and confirms the install is working before you lose access to your existing data.
What you will lose
Before switching:
- Historical data stays in GA4. Antlytics starts from zero on install day. There is no way to backfill historical pageviews or events.
- Modelled data is not portable. GA4 uses machine learning to estimate traffic when consent is withheld. That modelled data exists only inside GA4's reporting layer.
- Acquisition channel history. Your channel groupings, attribution models, and campaign data from before the migration will only be accessible in GA4 going forward.
If you need to preserve historical GA4 data for analysis, export it to BigQuery or download CSV reports before you switch fully to Antlytics.
Step 1 — Install Antlytics
Option A: CLI (recommended)
npx @antlytics/init
The installer detects your framework, authenticates via browser OAuth, and installs the correct tracking component. It verifies that events are arriving before it exits.
Option B: Manual (Next.js App Router)
npm install @antlytics/analytics
In app/layout.tsx:
import { Analytics } from '@antlytics/analytics/next'
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<body>
{children}
<Analytics trackingId="your-tracking-id" />
</body>
</html>
)
}
Option C: Script tag (any framework)
In your <head>:
<script
defer
data-tracking-id="your-tracking-id"
src="https://cdn.antlytics.com/tracker.js"
></script>
Step 2 — Run both tools in parallel
Leave GA4 in place while you run Antlytics. Both tools will collect data independently. Use this period to:
- Confirm Antlytics numbers are in the expected range compared to GA4
- Set up conversion goals in Antlytics to match any GA4 goals you use regularly
- Train your team on the Antlytics dashboard
Antlytics and GA4 will not produce identical numbers — they use different counting methods (GA4 uses sessions with session timeout logic; Antlytics counts unique session IDs). A 10–20% variance is normal. What you are checking is that the relative patterns match: similar top pages, similar referrer distribution, similar day-of-week trends.
Step 3 — Configure conversion goals
If you use GA4 goal tracking, recreate your key goals in Antlytics before removing GA4.
Via the MCP server (if you have it configured):
Create a goal called "Thank you page" for visits to /thank-you on my site.
Via the dashboard:
Go to Settings → Goals, click Add goal, enter a name and the path pattern.
Step 4 — Remove GA4
When you are confident Antlytics is working correctly:
If you installed via GTM:
- Open Google Tag Manager
- Find the GA4 Configuration tag and the GA4 Event tags
- Set their trigger to "Never fire" or delete them
- Publish the container
If you installed the gtag.js script directly:
Remove the <script> tags from your layout. There are typically two: the initial gtag.js loader and the config call.
If you use a WordPress plugin (Site Kit, MonsterInsights, etc.):
Deactivate or delete the plugin from the WordPress admin. Check that no other plugin is loading gtag.js (page source search for googletagmanager.com or gtag/js).
Step 5 — Remove consent banners (if applicable)
GA4 requires a cookie consent banner in most jurisdictions because it sets persistent cookies. Antlytics does not use cookies and does not store personal data, so a cookie consent popup is not required.
If your only reason for a consent banner was GA4, you can remove it after completing the migration. Always verify with your own legal counsel for your specific use case and jurisdiction.
Verifying the migration is complete
After removing GA4, confirm:
- No requests to
googletagmanager.comorwww.google-analytics.comin the browser network tab - No
_gaor_gidcookies set - Antlytics dashboard showing expected traffic levels
If you have the MCP server configured, you can ask your AI agent:
Check that my Antlytics install is receiving data for my site.
Common issues
Pageviews are lower than GA4 reported. Antlytics blocks known bot traffic. GA4 with basic bot filtering also blocks some bots, but the filter sets differ. If your site receives significant bot traffic, Antlytics numbers may be lower. This typically represents more accurate human visitor counts, not missing data.
Country or referrer data is missing.
Ensure your server or CDN is forwarding the CF-Connecting-IP, X-Forwarded-For, or equivalent header to the Antlytics ingest endpoint. See the troubleshooting guide for header forwarding configuration.
SPA navigations are not tracked.
The @antlytics/analytics/next component handles Next.js App Router soft navigation automatically. For other frameworks, check the framework-specific guide for your setup.