Installation Guide · React Native
How to Add Agent Analytics to Your Website
One script captures what visitors browse. That becomes memory your analytics can understand. And agents like Jack turn it into actions — recovery emails, demand segments, conversion insights.
Install on React Native
React Native
Use the @tradly/analytics SDK for React Native apps. It needs no native dependency — events are sent straight to the Tradly endpoint with offline queueing, retries, and batching built in.
Install the SDK
Add the @tradly/analytics package to your React Native project.
The package has zero dependencies and ships with TypeScript definitions.
npm install @tradly/analyticsCreate the analytics client
Create the client once at the top of your app and reuse it everywhere.
The projectKey is your public tenant/project identifier issued by Tradly. It is not a secret. Pass the app name, version, and platform so events are tagged correctly.
import { createAnalytics } from "@tradly/analytics";
export const analytics = createAnalytics({
projectKey: "your-tenant-id",
app: {
name: "My App",
version: "1.0.0",
platform: "ios", // ios, android, web, or omit
},
});Events stay queued and retry on the next flush if they fail to send.
await analytics.track("button_click", { name: "signup" });Call identify after your own auth flow. Do not use an email address as the identifier.
await analytics.identify("tenant:123:user:456");Native apps use in-memory persistence by default. Pass a synchronous storage adapter backed by secure/local storage if identity should survive app restarts.
Troubleshooting (3 common issues)
- →The default event-ingestion URL is https://analytics.tradly.dev — no extra configuration needed
- →The projectKey must be the tenant/project identifier from the dashboard, not a secret token
- →Event names like screen_view, button_click, app_error, listing_view, add_to_cart, checkout_started, and purchase_completed are recognized in the dashboard
Screen tracking with React Navigation
The SDK never inspects navigation automatically. Add one root-level onStateChange hook so every screen transition is tracked centrally.
Screen events appear in the dashboard's page and traffic reports.
import { NavigationContainer, createNavigationContainerRef } from "@react-navigation/native";
import { createAnalytics } from "@tradly/analytics";
const navigationRef = createNavigationContainerRef();
const analytics = createAnalytics({ projectKey: "your-tenant-id" });
let previousRouteName: string | undefined;
function trackCurrentScreen() {
if (!navigationRef.isReady()) return;
const route = navigationRef.getCurrentRoute();
if (!route || route.name === previousRouteName) return;
previousRouteName = route.name;
void analytics.screen(route.name);
}
<NavigationContainer
ref={navigationRef}
onReady={trackCurrentScreen}
onStateChange={trackCurrentScreen}
>
{/* your Stack, Tabs, or Drawer */}
</NavigationContainer>You can call analytics.screen directly with custom properties.
await analytics.screen("Checkout", { flow: "purchase" });Need help? Contact support@tradly.dev or check our FAQ.
Last updated: January 2025