@vikashruke/react-native-sdk
v1.1.0
Published
Plug-and-play marketing analytics & attribution for React Native apps. Measure installs, signups, conversions, revenue and campaign performance with Nurdd.
Maintainers
Readme
@vikashruke/react-native-sdk
Plug-and-play marketing analytics & attribution for React Native apps, powered by Nurdd. Drop it into your app and start measuring where your installs, signups and revenue actually come from — no data pipeline to build, no analytics backend to run.
What you can measure
- 📲 App installs — know how many users install your app and which campaign brought them in.
- 🔗 Campaign attribution — tie installs, signups and purchases back to the marketing link a user originally tapped, even across an app-store install. Measure the ROI of each campaign.
- 🙋 Signups & user identity — connect anonymous activity to a known user once they sign up or log in.
- 💳 Conversions & revenue — track purchases, subscriptions and any custom goal, with value and currency.
- 📊 Engagement & sessions — automatic session and app-open analytics so you can see how often and how long people use your app.
- 🧩 Custom events — track any in-app action that matters to your funnel.
Everything shows up in your Nurdd dashboard, ready to slice by campaign, cohort and conversion.
Install
yarn add @vikashruke/react-native-sdk @react-native-async-storage/async-storage
# recommended for the most accurate install attribution:
yarn add react-native-device-infoor with npm:
npm install @vikashruke/react-native-sdk @react-native-async-storage/async-storage react-native-device-infoRequirements: React Native ≥ 0.72, React ≥ 18.
Quick start
Wrap your app once with NurddProvider. Your SDK key and API URL
are available in your Nurdd dashboard.
import { NurddProvider } from '@vikashruke/react-native-sdk';
const config = {
sdkKey: 'sdk_pk_xxx', // from your Nurdd dashboard
baseUrl: 'https://api.nurdd.club', // from your Nurdd dashboard
appVersion: '1.0.0', // optional
debug: __DEV__, // optional: verbose logs in dev
};
export default function App() {
return (
<NurddProvider config={config}>
<Root />
</NurddProvider>
);
}That's the whole setup. Installs, app-opens and sessions are tracked automatically from here.
Configuration options
| Option | Default | Description |
| -------------------- | --------- | ---------------------------------------------------------- |
| sdkKey (required) | — | Your public SDK key from the Nurdd dashboard. |
| baseUrl (required) | — | Your Nurdd API URL from the dashboard. |
| appVersion | auto | Your app version. Auto-detected when available. |
| debug | false | Print verbose logs while developing. |
| trackInstall | true | Automatically record the first install. |
| trackAppOpen | true | Automatically record app opens. |
| sessionTimeoutMs | 1800000 | Inactivity (ms) after which a session is considered ended. |
| flushIntervalMs | 5000 | How often (ms) pending analytics are delivered. |
| maxBatchSize | 50 | Maximum number of events delivered at a time. |
| onError | — | Called when an attribution call permanently fails, so you can surface delivery problems. |
Tracking your marketing funnel
Track custom events
import { useTrack } from '@vikashruke/react-native-sdk';
function ProductScreen() {
const track = useTrack();
return (
<Button
title='Add to cart'
onPress={() => track('add_to_cart', { product_id: 'pro_monthly' })}
/>
);
}Identify a user
Call identify when a user signs up or logs in so their activity is tied
to a known profile.
import { useIdentity } from '@vikashruke/react-native-sdk';
function useLogin() {
const { identify } = useIdentity();
return async (userId: string, email: string) => {
await identify(userId, { email });
};
}Record a signup conversion
import { useNurdd } from '@vikashruke/react-native-sdk';
const sdk = useNurdd();
await sdk.signup({ externalUserId: 'user_123', email: '[email protected]' });Record a purchase
await sdk.purchase({ value: 49.99, currency: 'USD', productId: 'pro_monthly' });Record any custom conversion
await sdk.conversion('subscription_started', { value: 9.99, currency: 'USD' });Measure campaign attribution
When a user arrives from one of your marketing links, the SDK surfaces the campaign so you can route them to the right screen. Every signup and purchase the user makes afterward is automatically credited to that campaign — no extra code needed.
import { useDeepLink } from '@vikashruke/react-native-sdk';
function Root() {
useDeepLink((link) => {
// The user came from a Nurdd marketing link.
// Route them to the destination they expected:
if (link.deep_link_path) {
navigation.navigate(link.deep_link_path);
}
});
return <YourNavigator />;
}Reset on logout
Clear the current user’s identity when they log out. Anonymous analytics continue for the device.
const { reset } = useIdentity();
reset();API reference
Hooks
useNurdd(); // access the SDK instance
useTrack(); // (event, properties?) => void — track a custom event
useIdentity(); // { identity, identify(userId, traits?), reset() }
useDeepLink(cb); // run a callback when the user arrives from a campaign linkSDK methods
sdk.track(event, properties?) // track a custom event
sdk.identify(userId, traits?) // attach a known user
sdk.reset() // clear the current user
sdk.signup({ externalUserId?, email?, phone?, shortCode? }) // record a signup
sdk.purchase({ value, currency, productId?, shortCode? }) // record a purchase
sdk.conversion(type, { value?, currency?, shortCode?, ... }) // record a custom conversion
sdk.onDeepLink(listener) // subscribe to campaign links
sdk.ready() // resolves once attribution is ready
sdk.flush() // deliver pending analytics nowsignup(), purchase() and conversion() attribute to the user’s campaign
automatically. You can also pass shortCode explicitly to attribute to a
specific campaign.
Reliable delivery
Everything you record — custom events and conversions (signups,
purchases) — is stored on-device first and delivered reliably. If the
network drops or the app is closed mid-send, the data is retried
automatically the next time your app has connectivity; nothing is lost. You
don’t manage any of this. If a call is permanently rejected, your optional
onError handler is notified so you can surface it.
Privacy
The SDK collects standard mobile analytics signals (such as device model,
OS version, locale and app version) to power attribution and analytics.
Advertising identifiers are only used when your app includes
react-native-device-info and the user’s OS permissions allow it. Make
sure your app’s privacy policy and App Store / Google Play disclosures
reflect your analytics usage.
License
MIT
