Skip to content

How to migrate from Google Analytics 4 to Appwrite Analytics

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.

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

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 4Appwrite Analytics
CookiesFirst-party cookies that last up to 2 yearsNo cookies or browser storage
ConsentConsent Mode blocks or models visitors who decline cookiesBuilt to measure without cookies and honors Do Not Track
Returning visitorsRecognized across days by cookieVisitor ID resets daily; signed-in users identified through Appwrite Auth
Bots and AI trafficKnown bots hidden from reportsBots, AI crawlers, and AI assistants labeled and shown, with a separate AI referral channel
Script sizeAbout 155 KB compressedAbout 19 KB compressed, added automatically on Appwrite Sites
Where it livesA separate Google product that links to Google AdsThe same Appwrite project as Auth, Databases, Functions, and Sites
AnalysisStandard reports, Explorations, funnels, cohorts, BigQuery exportOne dashboard with filters, comparisons, PDF and CSV export, and an API
HistoryLong-term standard reports; Explorations keep 2 or 14 months30 days on Free, 90 on Start and Pro, up to 180 on Enterprise
PriceFree, with paid Analytics 360Included 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

Create a property in Analytics using the setup guide for websites or mobile apps. 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

Start from an existing GA4 event call:

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

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

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.

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

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 for details on sending events from backend code.

Node.js
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

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

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

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 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

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.

Resources

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.

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.

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.

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.

Read next