Track screens, sessions, app versions and devices, plus your own events, in the same dashboard as your website. The SDK works in Expo Go and needs no config plugin.
In the dashboard, choose Add website or app, then Mobile app. Enter the app's name and bundle ID. You get a tracking ID and the exact code for your app.
npx expo install @thravic/react-native @react-native-async-storage/async-storagenpm install @thravic/react-native @react-native-async-storage/async-storage
npx pod-installCall init once, as early as you can, with the values from your dashboard:
import { Thravic } from '@thravic/react-native';
Thravic.init('TF-1A2B3C4D', {
bundleId: 'com.acme.shop',
appVersion: '1.4.0',
});| Option | Default | What it does |
|---|---|---|
bundleId | 'app' | Your bundle ID. Screens are recorded as app://com.acme.shop/Home. |
appVersion | none | Shown under Versions. In Expo, use Application.nativeApplicationVersion from expo-application. |
apiUrl | Thravic | Where events are sent. The code in your dashboard fills it in. |
sessionTimeoutMinutes | 30 | Time in the background after which the next open starts a new session. |
flushIntervalSeconds | 10 | How often queued events are sent. |
debug | false | Log every event to the console. |
import { NavigationContainer, createNavigationContainerRef } from '@react-navigation/native';
import { Thravic } from '@thravic/react-native';
const navigationRef = createNavigationContainerRef();
export default function App() {
return (
<NavigationContainer ref={navigationRef} onReady={() => Thravic.trackNavigation(navigationRef)}>
{/* ... */}
</NavigationContainer>
);
}// app/_layout.tsx
import { Stack, useNavigationContainerRef } from 'expo-router';
import { useEffect } from 'react';
import { Thravic } from '@thravic/react-native';
Thravic.init('TF-1A2B3C4D', { bundleId: 'com.acme.shop' });
export default function Layout() {
const ref = useNavigationContainerRef();
useEffect(() => Thravic.trackNavigation(ref), [ref]);
return <Stack />;
}Thravic.screen('Checkout');Thravic.track('purchase', { amount: 49, currency: 'USD' });
Thravic.identify('user-42');Use your events as funnel steps, or send them to your own systems with webhooks.
Thravic.optOut(); // stops tracking and drops unsent events; remembered across launches
Thravic.optIn();
Thravic.isOptedOut();The SDK stores a random visitor ID on the device. It doesn't read the advertising ID, contacts, location or any other data that needs a permission. Thravic gets the country from the request IP and then discards the IP.
Create a free account to get your tracking ID.