The Alytica React Native SDK provides a simple way to track user behavior in your React Native applications. This document details the installation process and explains how to use the React Native SDK within your mobile app.
A React Native SDK for integrating with the Alytica analytics platform. Track events, identify users, and gain valuable insights into your app's performance and user behavior.
// Associate a user ID with the current useralytica.identify('user123');// Associate a user ID with additional propertiesalytica.identify('user123', { name: 'John Doe', email: 'john@example.com', plan: 'premium'});
// Associate a user with a groupalytica.group('company', 'acme_inc');// With additional propertiesalytica.group('company', 'acme_inc', { plan: 'enterprise', employees: 500});
import { usePathname, useSegments } from 'expo-router';import Alytica from 'alytica-react-native';const alytica = new Alytica({ clientId: 'YOUR_CLIENT_ID', api_host: 'https://api.alytica.tech',});function RootLayout() { // ... const pathname = usePathname(); // Segments is optional but can be nice to have if you // want to group routes together // pathname = /posts/123 // segments = ['posts', '[id]'] const segments = useSegments(); useEffect(() => { // Simple alytica.track('screen_view', { screen: pathname }); // With extra data alytica.track('screen_view', { screen: pathname, // segments is optional but nice to have segments: segments.join('/'), // other optional data you want to send with the screen view }); }, [pathname, segments]); // ...}