Adopture Docs
SDKsReact Native

Tracking Events

Track custom events and screen views with the Adopture React Native SDK.

Custom Events

Track any user action with a name and optional properties:

With hooks

import { useTrack } from '@adopture/react-native/react';

function CheckoutButton() {
  const track = useTrack();

  return (
    <Button
      title="Buy Now"
      onPress={() => track('purchase_started', {
        product: 'pro_plan',
        source: 'settings',
      })}
    />
  );
}

Imperative

import { Adopture } from '@adopture/react-native';

Adopture.track('purchase_started', {
  product: 'pro_plan',
  source: 'settings',
});

Screen Views

Track when a user views a screen:

With hooks

import { useScreen } from '@adopture/react-native/react';

function SettingsScreen() {
  const screen = useScreen();

  useEffect(() => {
    screen('settings');
  }, [screen]);

  return <View>...</View>;
}

Imperative

Adopture.screen('settings', { tab: 'privacy' });

For automatic screen tracking with React Navigation, see Navigation Tracking.

Event Properties

Properties are key-value pairs of strings attached to events:

track('button_clicked', {
  button_name: 'sign_up',
  screen: 'onboarding',
  variant: 'blue',
});

Limits:

  • Maximum 50 properties per event
  • Property values are truncated at 500 characters

Sending Events

Events are queued locally and sent in batches:

  • Batch interval: Every 30 seconds (configurable via flushIntervalMs)
  • Batch threshold: When 20 events are queued (configurable via flushAt)
  • Max batch size: 100 events per request

To send all queued events immediately:

await Adopture.flush();

This is useful before the app goes into the background or when you want to ensure events are delivered.

On this page