GuidesMobile

React Native analytics, cookieless and EU-hosted

Screen views and custom events for Expo and React Native, hosted in the EU.

Privytics is managed product analytics for React Native and Expo apps, built on the open-source OpenPanel engine. You install the @openpanel/react-native SDK, point it at the Privytics ingestion API, and start sending screen views and custom events. Setup is a client instance in one file plus a hook for navigation changes.

Why React Native teams use Privytics

Screen views, not page URLs

Mobile apps do not have page loads. The SDK exposes screenView(), so you record the route name from expo-router or React Navigation with whatever params matter, and funnels are built from real screens instead of guessed URLs.

No cookies and nothing written to the device

Privytics is cookieless by default. The anonymous visitor id is computed server side and resets every day. There is no advertising identifier and no local identifier persisted for analytics, which keeps the answers you give in App Store and Play Store privacy questionnaires short.

Events survive going offline

Phones lose signal in lifts, tunnels and planes. The SDK accepts a storage and a networkInfo adapter, so events queue on the device while offline and flush when the connection returns instead of being dropped. Queued events carry a __timestamp so they are recorded at the time they happened, not the time they were delivered.

Event data is stored in the EU

Ingested events are stored in EU data centres in Germany. If your app ships in the EU, that keeps the storage answer in your records of processing simple. You remain the controller for what you choose to send.

Set it up

About five minutes, on the free plan, without a credit card.

  1. Install the SDK

    The SDK depends on expo-application for build and version numbers (and the referrer on Android), and expo-constants for the user agent.

    npm install @openpanel/react-native
    npx expo install expo-application expo-constants
  2. Create the client

    Put the instance in one shared file and import it everywhere. apiUrl must be set to the Privytics ingestion host, otherwise the SDK sends to its default host. React Native needs a clientSecret because native apps cannot use CORS headers the way browsers do.

    // lib/op.ts
    import { OpenPanel } from '@openpanel/react-native';
    
    export const op = new OpenPanel({
      apiUrl: 'https://api.privytics.com',
      clientId: 'YOUR_CLIENT_ID',
      clientSecret: 'YOUR_CLIENT_SECRET',
    });
  3. Track screen views

    With Expo Router, call screenView whenever the pathname changes. React Navigation users can call the same method from onStateChange using the current route name.

    import { usePathname, useSegments } from 'expo-router';
    import { useEffect } from 'react';
    import { op } from '@/lib/op';
    
    export default function RootLayout() {
      const pathname = usePathname();
      const segments = useSegments();
    
      useEffect(() => {
        op.screenView(pathname, {
          segments: segments.join('/'),
        });
      }, [pathname, segments]);
    
      return (/* Your layout JSX */);
    }
  4. Track events and identify users

    Global properties are attached to every event. identify() links sessions into one profile using your own user id, so it is opt-in and needs your own lawful basis. Call clear() on logout to reset the identity.

    import { Platform } from 'react-native';
    import { op } from '@/lib/op';
    
    op.setGlobalProperties({
      app_version: '1.0.0',
      platform: Platform.OS,
    });
    
    op.track('button_clicked', {
      button_name: 'signup',
      screen: 'home',
    });
    
    op.identify({
      profileId: user.id,
      firstName: user.firstName,
      lastName: user.lastName,
      email: user.email,
      properties: {
        plan: user.plan,
      },
    });
    
    // on logout
    op.clear();
  5. Queue events while offline

    Install the two optional peer dependencies, then pass them to the constructor as the storage and networkInfo options. Events are held on the device and sent once connectivity returns.

    npm install @react-native-async-storage/async-storage @react-native-community/netinfo
  6. Pass the offline adapters to the client

    Update your shared client file to include the two adapters. Everything else stays the same, including apiUrl.

    // lib/op.ts
    import AsyncStorage from '@react-native-async-storage/async-storage';
    import NetInfo from '@react-native-community/netinfo';
    import { OpenPanel } from '@openpanel/react-native';
    
    export const op = new OpenPanel({
      apiUrl: 'https://api.privytics.com',
      clientId: 'YOUR_CLIENT_ID',
      clientSecret: 'YOUR_CLIENT_SECRET',
      storage: AsyncStorage,
      networkInfo: NetInfo,
    });

Privytics runs the open-source OpenPanel engine, so the upstream React Native SDK reference applies here too. Point apiUrl at Privytics and the data lands in your Privytics project.

Questions

Does this work with Expo?

Yes. The SDK installs its two Expo peer dependencies through npx expo install, and the screen view example uses expo-router hooks directly. It also works in bare React Native projects on iOS and Android.

Do I need cookies or an advertising ID to track a React Native app?

Not with Privytics. Tracking is cookieless by default and nothing is written to the device for identification. The anonymous visitor id is a salted hash of IP, user agent and project id that rotates at midnight UTC.

Why does the React Native SDK need a clientSecret when the web SDK does not?

Native apps cannot use the CORS headers that browsers send, so the SDK authenticates with a client secret instead. This is documented behaviour of @openpanel/react-native, not a Privytics-specific requirement.

What happens to events if the user is offline?

If you pass a storage adapter and a networkInfo adapter to the constructor, events are queued on the device and flushed when the connection comes back. Each queued event carries a __timestamp so it is recorded at the time it happened. Without those adapters, the SDK has nowhere to buffer.

Where is the data stored?

Event data is stored in EU data centres in Germany. Privytics runs the open-source OpenPanel engine but is an independent service and is not affiliated with or endorsed by OpenPanel.