---
layout: post
title: "How to migrate from Google Analytics 4 to Appwrite Analytics"
description: Move from Google Analytics 4 to Appwrite Analytics, step by step. Keep your custom events and campaign links, and get cookieless tracking with bot and AI traffic labeled on one dashboard.
date: 2026-11-30
cover: /images/blog/migrate-from-google-analytics-to-appwrite-analytics/cover.avif
timeToRead: 6
author: atharva
category: tutorials
featured: false
faqs:
  - question: "Can Appwrite Analytics import historical data from Google Analytics 4?"
    answer: "No, Appwrite Analytics cannot import historical data from Google Analytics 4 today. Run both tools side by side for a few weeks and export key GA4 reports as PDF, CSV, or Google Sheets before removing the Google tag."
  - question: "Do existing UTM links and Google Ads click IDs work in Appwrite Analytics?"
    answer: "Yes. Appwrite reads utm_source, utm_medium, utm_campaign, utm_content, and utm_term from landing URLs, and gclid, gbraid, wbraid, msclkid, and dclid mark a visit as paid."
  - question: "Why do visitor numbers differ between GA4 and Appwrite Analytics?"
    answer: "GA4 recognizes returning visitors with a cookie that lasts across days and hides known bots. Appwrite sets no cookies, uses a visitor ID that resets daily, and labels bots instead of hiding them."
  - question: "How much does Appwrite Analytics cost?"
    answer: "Appwrite Analytics is included in Appwrite Cloud plans, with Free covering 50K events a month per organization, 1 property per project, and 30 days of history. Start includes 50K events a month per project and Pro includes 100K events a month per project, both with unlimited properties, 90 days of history, and $3 per additional 100K events."
---

Most sites default to Google Analytics 4 because it is free. It identifies visitors with first-party cookies lasting up to two years. In the EU and UK, that usually means a consent banner; visitors who decline disappear from reports or become modeled estimates through Google's Consent Mode. Its tag adds about 155 KB of compressed JavaScript per page, and it filters only known bots, silently and without labels, so AI crawlers and agents reading a site either vanish from reports or show up as ordinary visitors. For Appwrite apps, it is another tool separate from the users and backend it measures.

Appwrite Analytics does not import GA4 history and counts visitors differently, so numbers will not line up on day one. The safe path: run both side by side for a few weeks, port tracking and events, understand why counts differ, then remove the Google tag once Appwrite holds enough history.

# How Appwrite Analytics differs from GA4

![The Appwrite Analytics dashboard showing unique visitors, visits, pageviews, events, bounce rate, and a 30-day comparison chart](/images/blog/migrate-from-google-analytics-to-appwrite-analytics/dashboard.avif)

Google Analytics 4 and Appwrite Analytics answer the same traffic questions, but they are built on different assumptions about privacy, bots, and where analytics belongs.

| | Google Analytics 4 | Appwrite Analytics |
| --- | --- | --- |
| Cookies | First-party cookies that last up to 2 years | No cookies or browser storage |
| Consent | Consent Mode blocks or models visitors who decline cookies | Built to measure without cookies and honors Do Not Track |
| Returning visitors | Recognized across days by cookie | Visitor ID resets daily; signed-in users identified through Appwrite Auth |
| Bots and AI traffic | Known bots hidden from reports | Bots, AI crawlers, and AI assistants labeled and shown, with a separate AI referral channel |
| Script size | About 155 KB compressed | About 19 KB compressed, added automatically on Appwrite Sites |
| Where it lives | A separate Google product that links to Google Ads | The same Appwrite project as Auth, Databases, Functions, and Sites |
| Analysis | Standard reports, Explorations, funnels, cohorts, BigQuery export | One dashboard with filters, comparisons, PDF and CSV export, and an API |
| History | Long-term standard reports; Explorations keep 2 or 14 months | 30 days on Free, 90 on Start and Pro, up to 180 on Enterprise |
| Price | Free, with paid Analytics 360 | Included in Appwrite plans, with 50K events a month on Free |

The tracking APIs still map one to one (a property for a data stream, `track()` for `gtag()` events, server events for Measurement Protocol, the **Identify signed-in users** setting for `user_id`, and `listMetrics` for the Data API), and the sections below cover each one.

# Add Appwrite next to the Google tag

![The Install tracking screen in the Appwrite Console confirming that the first pageview event arrived](/images/blog/migrate-from-google-analytics-to-appwrite-analytics/install-tracking.avif)

Create a property in Analytics using the setup guide for [websites](/blog/post/add-appwrite-analytics-to-your-website) or [mobile apps](/blog/post/add-appwrite-analytics-to-your-mobile-app). Add the tracker script to `<head>` next to the existing Google tag; both run on the same page without interfering. Keep GA4 running alongside Appwrite for 2 to 4 weeks to compare the numbers before removing it.

```html
<script defer src="https://sdk.appwrite.io/web/29.4.0/tracker.js"
        data-endpoint="https://<REGION>.cloud.appwrite.io/v1"
        data-project="<PROJECT_ID>"
        data-property="<PROPERTY_ID>"></script>
```

Bundled apps call `tracking.start()` from the `appwrite` Web SDK instead of adding the script tag. Sites hosted on Appwrite Sites need neither: turn on **Web analytics** in the site's settings, and Appwrite adds the tracker on production domains.

# Port custom events

![The Custom events card on the Analytics dashboard listing add_to_cart, checkout_started, purchase_completed, and newsletter_signup](/images/blog/migrate-from-google-analytics-to-appwrite-analytics/custom-events.avif)

Start from an existing GA4 event call:

```js
gtag('event', 'sign_up', {
    plan: 'pro',
    source: 'pricing_page',
});
```

Send the same event to Appwrite Analytics with `track()`:

```client-web
tracking.track('signup_completed', {
    props: { plan: 'pro', source: 'pricing_page' },
});
```

- Props take up to 16 string key-value pairs per event. Values are ranked by count and never summed, so keep amounts such as revenue in your database.
- Automatic events cover `pageview` (including single-page app route changes), `outbound_link`, `scroll_depth`, and `engagement_time`. GA4 enhanced measurement for forms, site search, and YouTube embeds becomes custom events.
- Background events such as heartbeats take `interactive: false` so they do not clear a visit's bounce.

# Keep your UTM links

![The Traffic sources card on the UTM campaigns tab listing each campaign by unique visitors](/images/blog/migrate-from-google-analytics-to-appwrite-analytics/campaigns.avif)

Existing campaign links keep working without edits. Appwrite reads `utm_source`, `utm_medium`, `utm_campaign`, `utm_content`, and `utm_term` from landing URLs, places visits with `gclid`, `gbraid`, `wbraid`, `msclkid`, or `dclid` in the paid channel, and strips the rest of the query string from stored URLs.

Campaign results appear under **Campaigns** in the **Traffic sources** card.

# Replace Measurement Protocol with server events

![The Create API key panel in the Appwrite Console with the analytics.write scope selected](/images/blog/migrate-from-google-analytics-to-appwrite-analytics/api-key.avif)

Server events replace GA4 Measurement Protocol requests and require an API key with the `analytics.write` scope. Passing the visitor's `ip` and `userAgent` joins the event to their browser visit, while passing `userId` attributes it to one of your users. Read [Track events from your server](/docs/products/analytics/server-side) for details on sending events from backend code.

```server-nodejs
import { Client, Analytics } from 'node-appwrite';

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>')
    .setKey(process.env.APPWRITE_API_KEY);

const analytics = new Analytics(client);

await analytics.createEvent({
    propertyId: '<PROPERTY_ID>',
    name: 'purchase_completed',
    url: 'https://example.com/checkout',
    ip: '<VISITOR_IP>',
    userAgent: '<VISITOR_USER_AGENT>',
    props: ['plan', 'pro', 'interval', 'yearly'],
});
```

Server SDKs take `props` as a flat list of keys and values.

# Replace user_id with Appwrite Auth

![The Analytics tab of a user in Auth showing events, visits, views, active days, and properties used over the last 30 days](/images/blog/migrate-from-google-analytics-to-appwrite-analytics/user-analytics.avif)

GA4 requires setting `user_id` when your users sign in and clearing it when they sign out. In Appwrite, turn on **Identify signed-in users** in the property's **Settings** tab so events from signed-in Appwrite Auth sessions carry the user's ID.

Appwrite stores only the ID, never an email or name. Each account in **Auth** gets an **Analytics** tab showing that user's last 30 days of activity.

# Find your GA4 reports in the Appwrite dashboard

![Filters popover with Channel, equal, and search selected](/images/blog/migrate-from-google-analytics-to-appwrite-analytics/filters.avif)

GA4's standard reports become one dashboard in Appwrite Analytics. Explorations such as funnels and cohorts have no equivalent yet.

- Filters apply across the whole dashboard by selecting any row or opening **Filters** for rules such as contains or starts with. Active filters live in the URL, so a link shares the exact view.
- Saved views store a filter for personal use or for the whole team.
- Comparisons pair every range against the previous period by default, or against the same period last year.
- Reports can be saved from **Export** as a PDF report or CSV data, or pulled by querying `listMetrics` with an `analytics.read` API key for automated reports.

# Why the numbers won't match

![Traffic sources card on the Channels tab, next to the Humans vs bots card](/images/blog/migrate-from-google-analytics-to-appwrite-analytics/traffic-sources.avif)

Totals between GA4 and Appwrite Analytics will differ during the side-by-side run because the two tools measure visits, bots, and attribution differently.

- Visitors are counted differently across days: GA4 recognizes returning visitors with a cookie that lasts up to 2 years, while Appwrite sets no cookies and uses a [visitor ID](/blog/post/how-cookieless-analytics-works-in-appwrite) that resets daily at 00:00 UTC. One person visiting on three days counts three times over that range.
- Bots are hidden in GA4, whereas Appwrite labels bots and AI agents and shows them. Web property totals include them until filtered to **Humans**.
- Bounces: both tools count a visit as engaged after two views or 10 seconds. GA4 also counts a key event, while Appwrite counts any interactive event.
- Attribution in GA4 credits a returning direct visit to the earlier source for up to 90 days. Appwrite uses each visit's own referrer and UTM parameters.
- Do Not Track is respected by default in the Appwrite Web SDK, which skips your visitors who turn it on.

# Remove the Google tag and mark the switch

![The Add note dialog in Appwrite Analytics with a date and note text field to mark a release or migration cutover on the chart](/images/blog/migrate-from-google-analytics-to-appwrite-analytics/add-note.avif)

On the day the Google tag comes off, use **Add note** on the Appwrite chart to mark the switch, so everyone on the team can see where GA4 data ends.

Before that, export the GA4 reports to keep: in GA4, open **Share this report** and select **Download File** to save a PDF, CSV, or Google Sheets copy. BigQuery export only covers dates after it is linked, so it cannot recover past data. Then remove `gtag.js` (or the GA4 tags in Google Tag Manager) and any leftover `gtag()` calls.

# Conclusion

Running analytics in the same project as Auth, Sites, and Firewall keeps traffic data alongside the rest of the stack with a lighter script. A side-by-side run lets a team switch without losing context. Bring questions about a migration to the [Appwrite Discord](https://appwrite.io/discord).

# Resources

- [Introducing Appwrite Analytics](/blog/post/introducing-appwrite-analytics)
- [How to add Appwrite Analytics to your website](/blog/post/add-appwrite-analytics-to-your-website)
- [How to add Appwrite Analytics to your mobile app](/blog/post/add-appwrite-analytics-to-your-mobile-app)
- [How cookieless analytics works in Appwrite Analytics](/blog/post/how-cookieless-analytics-works-in-appwrite)
- [Track custom events](/docs/products/analytics/custom-events)
- [Track events from your server](/docs/products/analytics/server-side)
- [Limits and retention](/docs/products/analytics/limits)
