Why Your Rork App Needs Product Analytics
After shipping your app, it's natural to wonder: "Where are users dropping off?" or "Is anyone actually using that new feature?" App Store Connect gives you download numbers and revenue figures, but it won't tell you what users are doing inside your app.
That's the gap product analytics fills. PostHog is open source, drops into a Rork (React Native / Expo) project without much ceremony, and once events start flowing you get to watch a funnel break at a specific step instead of guessing which one. Feature flags ride along with it, so a risky screen can reach five percent of users before it reaches everyone.
What you'll learn:
- What makes PostHog a strong choice for indie app developers
- Installing and configuring the PostHog SDK in a Rork project
- Tracking custom events and identifying users
- Building funnels to find where users drop off
- Using feature flags to release new features safely
What Is PostHog?
PostHog is an open-source product analytics platform that bundles everything a product team needs into a single tool. Unlike Mixpanel or Amplitude (which charge per event and lock features behind paid tiers), PostHog offers a generous free cloud tier and an optional self-hosted deployment.
Key capabilities include:
- Event Analytics: Track any user action and visualize it with charts, graphs, and trend views
- Funnel Analysis: Measure completion rates across multi-step flows like registration, onboarding, and checkout
- Session Replay: Watch recordings of real user sessions to discover friction points (mobile support varies by platform)
- Feature Flags: Ship features to specific user groups without a code deployment
- A/B Testing: Compare variants and make data-driven decisions
The free cloud plan covers up to 1 million events per month — more than enough for most indie apps at launch. If data sovereignty matters to you, the self-hosted Docker option lets you keep everything on your own infrastructure.
Step 1: Create a PostHog Account and Get Your API Key
Head to PostHog Cloud and create a free account. After signing in, create a new project and note your Project API Key (it starts with phc_). You'll need this in the next step.
You can always find your API key under Settings → Project → Project API Key in the PostHog dashboard.
Step 2: Install the SDK
Inside your Rork project directory, run:
# Install the PostHog React Native SDK
npm install posthog-react-native
# If you're using Expo, install the required native modules
npx expo install expo-file-system expo-application expo-device expo-localizationNext, wrap your app with the PostHogProvider in your root layout file:
// app/_layout.tsx (Expo Router)
import { PostHogProvider } from 'posthog-react-native';
export default function RootLayout() {
return (
<PostHogProvider
apiKey="YOUR_POSTHOG_API_KEY" // Your phc_ project key
options={{
host: 'https://us.i.posthog.com', // Use https://eu.i.posthog.com for EU
}}
>
<Stack />
</PostHogProvider>
);
}Tip: Store your API key in an .env file as EXPO_PUBLIC_POSTHOG_KEY rather than hardcoding it. PostHog public API keys (the phc_ ones) are client-side keys by design, but using environment variables keeps your codebase cleaner.
Step 3: Track Your First Events
With the provider in place, you can use the usePostHog hook in any component to send events to your dashboard.
// components/SubscribeButton.tsx
import { TouchableOpacity, Text } from 'react-native';
import { usePostHog } from 'posthog-react-native';
export function SubscribeButton() {
const posthog = usePostHog();
const handlePress = () => {
// Capture an event with optional properties
posthog.capture('subscribe_button_tapped', {
screen: 'HomeScreen',
plan: 'pro',
});
// Proceed with actual purchase logic
};
return (
<TouchableOpacity onPress={handlePress}>
<Text>Upgrade to Pro</Text>
</TouchableOpacity>
);
}Keep event names in snake_case (e.g., subscribe_button_tapped) for consistency. You can attach any properties that will help you slice and filter data later — screen names, user plan types, session metadata, and so on.
Step 4: Identify Users After Sign-In
By default, events are recorded for anonymous users. Once a user signs in, call identify to link all previous and future events to their account.
// hooks/useAuth.ts
import { usePostHog } from 'posthog-react-native';
export function useAuth() {
const posthog = usePostHog();
const signIn = async (userId: string, email: string) => {
// Your existing sign-in logic (Firebase Auth, Supabase, etc.)
await performSignIn(userId);
// Attach user info to PostHog
posthog.identify(userId, {
email: email,
plan: 'free',
created_at: new Date().toISOString(),
});
};
const signOut = async () => {
await performSignOut();
// Reset the session on sign-out
posthog.reset();
};
return { signIn, signOut };
}After calling identify, PostHog merges the anonymous pre-login events with the identified user's profile. This gives you a complete, continuous view of each user's journey from first open through conversion.
Step 5: Build a Funnel to Find Drop-Off Points
Funnels are one of the most actionable reports in any analytics tool. They show you exactly which step in a multi-step flow causes the most drop-off.
To build a funnel, simply fire an event at each step:
// screens/Onboarding.tsx
const handleStep1Complete = () => {
posthog.capture('onboarding_step1_completed'); // Profile setup done
setStep(2);
};
const handleStep2Complete = () => {
posthog.capture('onboarding_step2_completed'); // Notification preferences set
setStep(3);
};
const handleOnboardingComplete = () => {
posthog.capture('onboarding_completed'); // Full flow complete
router.push('/home');
};In the PostHog dashboard, navigate to Funnels, add these events in order, and PostHog will calculate the conversion rate at each step automatically. If you're seeing 80% of users complete Step 1 but only 40% reach Step 2, you know exactly where to focus your UX improvements.
For a deeper dive into improving user experience metrics hand-in-hand with analytics, check out the Rork App Performance Optimization Complete Guide — performance and user behavior are closely linked.
Step 6: Roll Out Features Safely with Feature Flags
Feature flags let you expose new functionality to a subset of your users without shipping a new app version. This is invaluable for testing risky UI changes or gradually rolling out a feature to avoid support overload.
// components/NewFeatureBanner.tsx
import { useFeatureFlagEnabled } from 'posthog-react-native';
export function NewFeatureBanner() {
// Create a flag called 'new-dashboard-ui' in the PostHog dashboard
const isEnabled = useFeatureFlagEnabled('new-dashboard-ui');
if (!isEnabled) return null;
return (
<View>
<Text>✨ Try our redesigned dashboard!</Text>
</View>
);
}From the PostHog dashboard, you can configure the flag to roll out to 10% of users, target users with a specific property (e.g., plan = 'pro'), or enable it for your own account only for testing. When you're confident the new experience works well, simply flip the flag to 100%.
Looking back
Adding PostHog to your Rork app gives you the visibility to make informed product decisions rather than relying on guesswork. Here's a quick recap of what we covered:
- PostHog is a free, open-source product analytics platform with event tracking, funnels, feature flags, and A/B testing all in one place
- Installing
posthog-react-nativeand wrapping your app withPostHogProvidertakes just a few minutes - Use
captureto record events andidentifyto tie them to specific users after sign-in - Funnel analysis helps you pinpoint exactly where users drop off in critical flows
- Feature flags let you ship new functionality safely and gradually
Moving from gut-feel decisions to data-driven ones is one of the highest-leverage shifts an indie developer can make. Even a simple funnel showing onboarding completion rates can reveal improvements that dramatically impact retention and revenue.
If you want to go deeper on monetization analytics, the Rork × RevenueCat Subscription Monetization Guide is a great next step — combining revenue data with behavioral data gives you the clearest picture of what's actually driving growth.