How to add Appwrite Analytics to your mobile app
Add Appwrite Analytics to an Android, iOS, React Native, or Flutter app. Track installs, screen views, time in the app, and custom events, and compare iOS and Android on one dashboard.

Appwrite Analytics shows how people use your mobile app: which screens they open, how long they stay, and what they do on each screen. One property can collect the events of your iOS and Android apps, so one dashboard shows both platforms side by side.
This tutorial adds Appwrite Analytics to an app built with Flutter, Kotlin on Android, SwiftUI on iOS, or React Native. Each code step has a tab for each platform. At the end, the app reports installs, screen views, time in the app, and custom events, and the property's dashboard shows them by screen and by platform.
Register your app in your project
Appwrite accepts events from an app only when its package name or bundle ID belongs to an app in your project.
- In the Appwrite Console, open your project and go to Apps.
- Select Add app.
- Select your platform: Android, Apple, Flutter, or React Native. For Apple, Flutter, and React Native, also select the target platform, such as iOS. Then select Continue.
- Enter a name and your app's package name or bundle ID, such as
com.example.acmestore. - Select Register and continue.
Repeat these steps for each target of the app, for example once for Android and once for iOS.
Create an analytics property
A property collects the events of one app or website, and each property has its own dashboard. Use one property for all platforms of an app, so that the dashboard can compare them.
- Go to Analytics and select Create property.
- Enter a Name, such as
Acme Shop app. - Under Type, select Mobile, and leave Domain empty.
- Under SDK, select Flutter for a Flutter app. For Android, Apple, and React Native, select REST: the Console has no snippet for those SDKs, and this guide covers their setup.
- Select Create property.
The Console opens the install page with your property ID. Keep it open: it confirms the first event that your app sends.
Install the SDK
Add the Appwrite SDK for your platform:
Add the appwrite package to your app:
flutter pub add appwrite
For Android builds, set minSdk to 24 and turn on core library desugaring in android/app/build.gradle.kts:
android {
defaultConfig {
minSdk = 24
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
}
Set compileSdk to 37 or later, and add the Appwrite SDK and Navigation Compose, which the screen view step uses, to app/build.gradle.kts:
dependencies {
implementation("io.appwrite:sdk-for-android:31.4.0")
implementation("androidx.navigation:navigation-compose:2.10.2")
}
In Xcode, select File > Add Package Dependencies. Enter the package URL, and add the Appwrite library to your app target:
https://github.com/appwrite/sdk-for-apple
In an Expo app, install the SDK with the file system module and the URL polyfill that it uses:
npx expo install react-native-appwrite expo-file-system react-native-url-polyfill
Start tracking
Create one Tracking instance for the whole app with your endpoint, project ID, and property ID, and call start() when the app launches. Copy the endpoint and the project ID from your project's Settings page. On Android, create it in your Application class and register that class in AndroidManifest.xml with android:name=".AcmeApp" on the <application> element. In React Native, pass the package name or bundle ID registered under Apps to setPlatform().
// lib/main.dart
import 'package:appwrite/appwrite.dart';
import 'package:flutter/material.dart';
final client = Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>');
final tracking = Tracking(Analytics(client), '<PROPERTY_ID>');
void main() {
tracking.start();
runApp(const AcmeApp());
}
// AcmeApp.kt
import android.app.Application
import io.appwrite.Client
import io.appwrite.Tracking
import io.appwrite.services.Analytics
class AcmeApp : Application() {
lateinit var tracking: Tracking
override fun onCreate() {
super.onCreate()
val client = Client(this)
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1")
.setProject("<PROJECT_ID>")
tracking = Tracking(Analytics(client), "<PROPERTY_ID>")
tracking.start()
}
}
// AcmeApp.swift
import Appwrite
import SwiftUI
let tracking: Tracking = {
let client = Client()
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1")
.setProject("<PROJECT_ID>")
return Tracking(Analytics(client), propertyId: "<PROPERTY_ID>")
}()
@main
struct AcmeApp: App {
init() {
tracking.start()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
// src/lib/analytics.ts
import 'react-native-url-polyfill/auto';
import { Analytics, Client, Tracking } from 'react-native-appwrite';
const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
.setProject('<PROJECT_ID>')
.setPlatform('com.example.acmestore');
export const tracking = new Tracking(new Analytics(client), '<PROPERTY_ID>');
tracking.start();
start() sends first_open after an install or app_updated after an update, and records when the app goes to the background and comes back, so installs and time in the app arrive with no other code. In React Native, import @/lib/analytics in the root layout, src/app/_layout.tsx, so tracking starts when the app launches. The screen view step shows the full file.
Confirm the first event
Run your app on a device or an emulator. Within a few seconds, the install page in the Console shows Event received with the first event. Select Open dashboard to see the session.
Track screen views
Send a screen_view each time a screen opens. Hook Tracking into your navigation, so that new screens send their views with no extra code:
// lib/main.dart
class AcmeApp extends StatelessWidget {
const AcmeApp({super.key});
Widget build(BuildContext context) {
return MaterialApp(
navigatorObservers: [TrackingObserver(tracking)],
routes: {
'/': (context) => const HomeScreen(),
'/product': (context) => const ProductScreen(),
},
);
}
}
// MainActivity.kt
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.LaunchedEffect
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val tracking = (application as AcmeApp).tracking
setContent {
val navController = rememberNavController()
LaunchedEffect(navController) {
navController.currentBackStackEntryFlow.collect { entry ->
entry.destination.route?.let { tracking.screenView(it) }
}
}
NavHost(navController, startDestination = "home") {
composable("home") { HomeScreen(onOpenProduct = { navController.navigate("product") }) }
composable("product") { ProductScreen() }
}
}
}
}
// ContentView.swift
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
NavigationLink("Open product") {
ProductView()
}
.onAppear { tracking.screenView("home") }
}
}
}
struct ProductView: View {
var body: some View {
Text("Canvas backpack")
.onAppear { tracking.screenView("product") }
}
}
// src/app/_layout.tsx
import { useEffect } from 'react';
import { Stack, usePathname } from 'expo-router';
import { tracking } from '@/lib/analytics';
export default function RootLayout() {
const pathname = usePathname();
useEffect(() => {
tracking.screenView(pathname);
}, [pathname]);
return <Stack />;
}
HomeScreen and ProductScreen stand for your own screens. Returning to a screen sends another screen view.
Track custom events
Screen views show where people go. Custom events record what they do, such as adding a product to the cart or completing a purchase. Send each event where the action completes, with the screen that it belongs to:
tracking.event(
'add_to_cart',
url: '/product',
props: {'product': 'canvas-backpack'},
);
tracking.event(
"add_to_cart",
url = "/product",
props = mapOf("product" to "canvas-backpack"),
)
tracking.event("add_to_cart", url: "/product", props: ["product": "canvas-backpack"])
tracking.track('add_to_cart', {
url: '/product',
props: { product: 'canvas-backpack' },
});
Give each event a lowercase snake_case name for a finished action, such as purchase_completed or review_posted. For naming and props, see Track custom events.
Read the dashboard
A Mobile property's dashboard uses app terms: Active users, Sessions, Screen views, Events, Signed-in users, Screens/session, Session length, and Engagement time. Select a metric to plot it on the chart against the previous period.
The dashboard opens filtered to Humans only, which leaves automated test devices out of the numbers. The online count in the header shows the people who used the app in the last five minutes.
Count installs and updates
The Installs card counts the first_open and app_updated events that start() sends. It shows how many people installed the app in the date range, and how many moved to a new version.
Find the screens people use most
The Screens card lists your screens by path. Top screens ranks all screens, Entry screens shows the screen where each session starts, and Exit screens shows the screen where it ends.
Compare iOS and Android
The Platforms tab of the Technology card splits your traffic by platform, such as iOS and Android. Select a row to filter the whole dashboard to one platform.
Conclusion
Your app is reporting its first sessions and screen views. We'd love to hear what turns up, so share your dashboard or ask a question on Discord.
Resources
Register your app's package name or bundle ID under Apps in your Appwrite project, create an analytics property with the Mobile type, and install the Appwrite SDK for your platform. Then create a Tracking instance with your property ID, call start() when the app launches, and send a screen view each time a screen opens.
Yes. Appwrite counts screen_view events as views, the same as pageview events on a website. On a Mobile property, the dashboard shows them as Screen views.
Tracking sends an app_backgrounded event when the app goes to the background, with engagementTime set to the seconds it was in the foreground. The dashboard shows the average engagement time per session.
Yes. Open the Platforms tab of the Technology card to compare iOS and Android, and select a row to filter the whole dashboard to one platform.
The Flutter, Android, Apple, and React Native SDKs all include a Tracking class that sends install, lifecycle, screen view, and custom events. Flutter also includes the TrackingObserver for routes. Any other platform can send events through the REST API.
Yes. start() sends first_open once per install and app_updated on the first launch after a new version. The Installs card on the dashboard counts both.





