React Native / Expo
Install the SDK, create the tracker, and start tracking app sessions.
Last updated June 3, 2026
Install Grometrics in a React Native or Expo app. This tracks app opens, screen views, lifecycle events, deep links, push opens, and revenue attribution. See what the SDK can do →.
Prerequisites
- A Grometrics site ID from Settings > Tracking
- React Native or Expo app access
- AsyncStorage installed for offline event queueing
Tip
Pass appVersion and appBuild explicitly. Expo apps can read those values from expo-constants in app code without making it a tracker dependency.
Identity lifecycle
The SDK records activity before identify, rotates visitor IDs after one year, discards queued events after 30 days, and resets automatically after an HTTP 410 erasure response.
Steps
Install packages
Add the React Native tracker and AsyncStorage.
terminal
1npm install @grometrics/react-native @react-native-async-storage/async-storageEnable native attribution in Expo
Add the config plugin, then create a new native build. Android captures Google Play Install Referrer automatically. The plugin sends Apple's signed aggregate SKAdNetwork postbacks to Grometrics.
app.json
1{2"expo": {3"plugins": ["@grometrics/react-native"]4}5}
Create the tracker
Pass your Grometrics site ID and optional app context.
Replace YOUR_SITE_ID with your site ID from Settings > Tracking.
App.tsx
1import { createReactNativeTracker } from '@grometrics/react-native'2import { createNavigationContainerRef } from '@react-navigation/native'34const navigationRef = createNavigationContainerRef()5const setup = await createReactNativeTracker({6websiteId: 'YOUR_SITE_ID',7navigationRef,8context: {9countryCode: 'US'10}11})
Start on app boot
Start after app initialization so app_open and the current screen are sent.
App.tsx
1await setup.tracker.start()23// React Navigation4<NavigationContainer5ref={setup.navigation.ref}6onReady={setup.navigation.onReady}7onStateChange={setup.navigation.onStateChange}8>
Identify after login and reset before sign-out
This merges earlier anonymous screens with later server and revenue activity, while reset keeps the next user separate on shared devices.
auth.ts
1await setup.tracker.identify(user.id)23// Before sign-out4await setup.tracker.reset()5await auth.signOut()
Options / Configuration
| Option | Type | Required | Description |
|---|---|---|---|
| websiteId | string | ✓ | Your Grometrics site ID from Settings > Tracking |
| appVersion | string | no | Populates app version filters and rollout reporting |
| appBuild | string | no | Build number shown with app version context |
| attribution | object | no | Custom deferred-link or consented attribution sources; deep links and Android install referrer are automatic |
| push | object | no | Captures push_opened events for push revenue attribution |
| navigationRef | object | no | Uses your React Navigation ref for screen_view events |
npm
1npm install @grometrics/react-native @react-native-async-storage/async-storageEvent model
| Event | Used for |
|---|---|
| app_open | Active users, realtime lifecycle feed, session starts |
| app_background / app_close | Active-session end, exit screens, realtime summaries |
| screen_view | Screens page, top screens, screen paths, screen context |
| push_opened | Push tab, event-level engagement attribution, realtime push rows |
| revenue | Dashboard revenue, attribution, sources, campaigns, recent sales |
Direct is normal
Mobile Direct is often larger than web because home screen opens, app switcher opens, Spotlight, ATT opt-outs, and missing referrers have no attribution context.
Danger
Do not send synthetic purchases from a production app unless you mark them as test events before verification.
What happens next
Open Realtime after starting the app. You should see app_open first, then screen_view events as you navigate.
Verify your setup
Verify your setup
Troubleshooting
No app_open appears
Confirm tracker.start() runs after app initialization and the site ID matches Settings > Tracking.
Screens are missing
Confirm the navigation callbacks are wired, or call screen_view manually for custom navigation.
Push opens are missing
Confirm push tracking is enabled and the notification payload includes the campaign or title field.
Was this page helpful?