Prerequisites
Before you begin, make sure you have the following ready:- A Tappd account and your App ID
- A React Native project running version 0.60 or later
- iOS: Xcode and CocoaPods installed
- Android: Android Studio installed
Your App ID connects the SDK to your Tappd project. Retrieve it from the dashboard before writing any code.
a1b2c3d4-e5f6-7890-abcd-ef1234567890Keep your App ID close by — you’ll need it in the next step. Treat it like an API key and avoid committing it directly to source control. Use environment variables in production.
Optionally, install
react-native-device-info to capture richer device metadata such as device model and app version. This package is recommended but not required.Android requires no additional linking. The SDK works out of the box on Android after the npm install.
Initialize the SDK at the top level of your app, before the root component mounts. Open
App.js or App.tsx and add the following.import React from 'react';
import TappdSDK from '@tappd/mobile-sdk';
const tappd = new TappdSDK({
appId: 'YOUR_APP_ID',
apiUrl: 'https://sdk.gotappd.com/api/v1/sdk',
autoTrack: true,
sessionTimeout: 30,
enableAutoScreenTracking: true,
debug: false
});
// Make it available throughout your app
global.tappd = tappd;
function App() {
return (
// Your app content
);
}
export default App;
Replace
YOUR_APP_ID with the App ID you copied from the dashboard. See the Configuration reference for a full breakdown of every available option.Call
identify() whenever a user logs in or signs up so that all future events are linked to their profile.async function handleLogin(userId, email, name) {
await tappd.identify({
external_id: userId, // Recommended: your own user ID
name: name,
email: email,
phone: '+1234567890',
// Any additional attributes you want to store
plan: 'premium',
age: 28
});
}
At least one identifier is required —
external_id, email, phone, or alias. Using external_id (your own user ID from your auth system) is recommended for the most reliable customer matching. The SDK handles its own internal tracking identifier automatically.After
identify() is called, all subsequent track() and trackScreen() calls are automatically associated with that user. You only need to call identify() once per login.Record screen views so you can see which parts of your app users visit most. Use
useFocusEffect from React Navigation to fire a screen event each time a screen comes into focus.import React from 'react';
import { View } from 'react-native';
import { useFocusEffect } from '@react-navigation/native';
function HomeScreen() {
useFocusEffect(
React.useCallback(() => {
global.tappd.trackScreen('HomeScreen', {
category: 'main',
section: 'dashboard'
});
}, [])
);
return <View>{/* screen content */}</View>;
}
When
autoTrack: true is set in your config, the SDK also automatically records these app lifecycle events without any additional code:app.openedapp.foregroundapp.backgroundapp.closedcleanup()Fire custom events to capture any user action that matters to your business — purchases, button clicks, form completions, and more.
// Track a purchase
await global.tappd.track('purchase', {
amount: 99.99,
currency: 'USD',
productId: 'prod_123'
});
// Track a button click
await global.tappd.track('button_click', {
buttonId: 'signup',
location: 'onboarding'
});
Project Setup Patterns
Choose the pattern that best fits how your project is structured. All three approaches produce the same result — pick the one that matches your team’s conventions.- Context Provider (Recommended)
- Custom Hook
- Global Variable
The Context pattern gives every component in your tree clean access to the SDK instance without relying on globals. Create a dedicated context file and wrap your app in the provider.Then wrap your root component with Access the SDK in any component using the
TappdProvider in App.js.useTappd hook.Verify Installation
Enabledebug: true when you first set up the SDK to confirm everything is working. With debug mode on, the SDK prints detailed logs to your React Native console.
Next Steps
Configuration
Customize every SDK option — session timeouts, polling intervals, in-app messages, and environment-based config.
React Navigation
Integrate automatic screen tracking with your React Navigation stack.
Push Notifications
Register FCM and APNs push tokens and manage notification subscriptions.
API Reference
Browse every method available on the TappdSDK instance with full parameter documentation.