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

1

Install packages

Add the React Native tracker and AsyncStorage.

terminal

1npm install @grometrics/react-native @react-native-async-storage/async-storage
2

Enable 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}
3

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({6  websiteId: 'YOUR_SITE_ID',7  navigationRef,8  context: {9    countryCode: 'US'10  }11})
4

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<NavigationContainer5  ref={setup.navigation.ref}6  onReady={setup.navigation.onReady}7  onStateChange={setup.navigation.onStateChange}8>
5

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

OptionTypeRequiredDescription
websiteIdstringYour Grometrics site ID from Settings > Tracking
appVersionstringnoPopulates app version filters and rollout reporting
appBuildstringnoBuild number shown with app version context
attributionobjectnoCustom deferred-link or consented attribution sources; deep links and Android install referrer are automatic
pushobjectnoCaptures push_opened events for push revenue attribution
navigationRefobjectnoUses your React Navigation ref for screen_view events

npm

1npm install @grometrics/react-native @react-native-async-storage/async-storage

Event model

EventUsed for
app_openActive users, realtime lifecycle feed, session starts
app_background / app_closeActive-session end, exit screens, realtime summaries
screen_viewScreens page, top screens, screen paths, screen context
push_openedPush tab, event-level engagement attribution, realtime push rows
revenueDashboard 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?