> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reyapp.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Analyze User Behavior and Watch Replays with PostHog

> Connect PostHog to Rey to automatically track events, watch session replays, analyze conversion funnels, and ask Rey AI data-driven UX questions.

PostHog is an open-source product analytics platform that combines event tracking, session replays, funnel analysis, and feature flags in a single tool. Connecting PostHog to Rey gives you a live window into how real users navigate your app — where they go, what they tap, where they slow down, and where they leave. You can then use that data directly with Rey AI to make faster, evidence-based product decisions.

## What PostHog Does

PostHog captures every meaningful action a user takes in your app and lets you analyze those actions as events, funnels, and retention curves. Its session replay feature records the full screen of a user's session so you can watch exactly what happened — no guessing required. PostHog is self-hostable, but the cloud version at [posthog.com](https://posthog.com) requires no infrastructure to set up.

## Prerequisites

Before connecting PostHog to Rey, make sure you have:

* A [PostHog account](https://posthog.com) with a project created.
* Your **PostHog API key** — find it in PostHog under **Project Settings → Project API Key**.

## Connect PostHog to Rey

<Steps>
  <Step title="Create a PostHog project and copy your API key">
    Log in to PostHog and create a new project (or use an existing one). Navigate to **Project Settings → Project API Key** and copy the key. This is a write-only ingestion key — it is safe to include in your app.
  </Step>

  <Step title="Enter your API key in Rey">
    In the Rey editor, open the **Integrations** panel, select **PostHog**, and paste your API key into the API Key field.
  </Step>

  <Step title="Save and verify the connection">
    Click **Save**. Rey activates the PostHog integration and begins sending events immediately. A green status indicator appears on the PostHog card in the Integrations panel. Open your PostHog dashboard and navigate to **Events** — you should see incoming events within a few seconds of your next app session.
  </Step>
</Steps>

## What Rey Tracks Automatically

Once connected, Rey sends the following events to PostHog without any additional configuration:

| Event          | Description                                               |
| -------------- | --------------------------------------------------------- |
| `$screen`      | Fired each time a user views a new screen                 |
| `$autocapture` | Captures button taps and interactive element interactions |
| `$navigate`    | Fired on every navigation action between screens          |

These events are enough to start building funnels, identify drop-off points, and watch session replays right away.

## Watch Session Replays

PostHog records full session replays of your users' in-app experience. To watch a replay:

1. In PostHog, go to **Session Replays** in the left sidebar.
2. Filter by date, user property, or event to find the sessions you care about.
3. Click any session to watch the recording. You'll see every tap, scroll, and screen transition exactly as the user experienced it.

<Tip>
  Filter session replays by users who reached a specific screen but didn't complete the next step — this is the fastest way to find friction in your onboarding or checkout flow.
</Tip>

## Analyze Funnels

Create conversion funnels in PostHog to measure how many users move through a multi-step flow — like onboarding, sign-up, or a purchase sequence.

1. In PostHog, go to **Insights → Create New Insight → Funnel**.
2. Add the steps of your flow as events (for example: `$screen: Welcome → $screen: Sign Up → sign_up_completed`).
3. PostHog calculates the conversion rate at each step and shows where users drop off.

Use funnels to prioritize which screens to improve first — fix the step with the biggest drop-off and watch your overall conversion rate climb.

## Ask Rey AI About Your PostHog Data

Rey AI can query your PostHog data directly to answer product questions in plain language. With PostHog connected, you can ask Rey AI things like:

* *"Where are users dropping off in onboarding?"*
* *"Which screen has the highest exit rate?"*
* *"How many users completed sign-up in the last 7 days?"*

Rey AI reads your PostHog event stream and surfaces the answer without you needing to build a chart or write a query.

<Tip>
  Combine PostHog session replays with Rey AI's data questions for the fastest path to UX improvements: ask Rey AI where users drop off, then watch the session replays from that exact screen to see why.
</Tip>

<AccordionGroup>
  <Accordion title="Can I send custom events to PostHog from Rey?">
    Yes. Add a **Track Event** action to any button, gesture, or trigger in the Rey editor. Enter a custom event name and optional properties. Those events appear in PostHog immediately and can be used in funnels, retention charts, and session replay filters.
  </Accordion>

  <Accordion title="Does PostHog work with feature flags?">
    Yes. You can create feature flags in the PostHog dashboard and use them to roll out new screens or features to a percentage of users. Rey reads PostHog feature flag values at runtime and can show or hide content based on flag state — ask Rey AI for guidance on setting this up.
  </Accordion>

  <Accordion title="Is PostHog GDPR compliant?">
    PostHog Cloud (EU region) and self-hosted PostHog are both GDPR-compliant. If you need data to stay in the EU, create your PostHog project in the EU cloud region. Rey does not require any additional configuration — just use the API key from your EU-region project.
  </Accordion>
</AccordionGroup>
