Install guides / Mobile apps

Add PageLens analytics to React Native / Expo

PageLens is cookieless website analytics: no consent banner, a ~3 KB script, real-time stats, funnels, session replay and AI-traffic insights. Setup on React Native / Expo takes about two minutes.

Steps

  1. Add your app in PageLens: Add Site → Mobile app.
  2. Install the SDK: npm install github:alibaizhanov/pagelens-react-native — pure JavaScript, no native modules, works in Expo Go and bare React Native on iOS and Android.
  3. Call PageLens.configure() once at startup and pass trackNavigation to React Navigation, as below. Track actions with PageLens.track("event").
  4. Nothing is stored on the device and no advertising ID is used, so no App Tracking Transparency prompt is needed. Declare “Product Interaction · Analytics” in App Store privacy details and the Google Play Data safety form.
import * as PageLens from 'pagelens-react-native';
import * as Application from 'expo-application'; // optional: app version

PageLens.configure({
  siteId: 'YOUR_SITE_ID',
  appVersion: Application.nativeApplicationVersion,
  appId: Application.applicationId,
});

export default function App() {
  const navigationRef = useNavigationContainerRef();
  return (
    <NavigationContainer
      ref={navigationRef}
      onReady={() => PageLens.trackNavigation(navigationRef.getRootState())}
      onStateChange={PageLens.trackNavigation}
    >
      {/* your navigators */}
    </NavigationContainer>
  );
}

// Anywhere:
PageLens.track('signup', { plan: 'pro' });
PageLens.identify(user.id);

Replace YOUR_SITE_ID with the id from your site settings in PageLens. The dashboard shows the exact snippet with your id filled in.

Check that it works

Open your site in a new tab, then open PageLens. The live counter shows your visit within a few seconds. Visits from localhost are ignored by default.

Track custom events

Add data-pagelens-event to any button or form, or call the JavaScript API:

<button data-pagelens-event="signup" data-pagelens-prop-plan="pro">Start trial</button>

<script>
  window.pagelens?.track('signup', { plan: 'pro' })
</script>

You can also turn on autocapture for button clicks, form submissions and copy events in Site Settings → Tracking. No code is needed.

Avoid ad blockers

Some ad blockers drop requests to analytics domains. Serve PageLens from your own domain to count those visits too.

Don't have a site ID yet?

Create a free PageLens account: 7-day trial, no card, no cookie banner needed.

Start free trial

Other mobile apps

iOS app (Swift)