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

# PostHog

> Set up PostHog for analytics

<Frame>
  <img src="https://mintcdn.com/shipmobilefast-51a499dc/rNBXOQ08cKXtmr3A/images/header/posthog.png?fit=max&auto=format&n=rNBXOQ08cKXtmr3A&q=85&s=6c627d076f899b18f7acdc9ef04f42b0" alt="PostHog" className="w-full h-full rounded-xl" width="700" height="320" data-path="images/header/posthog.png" />
</Frame>

## Quick Start

<Steps>
  <Step>
    First, go to the [PostHog Setup](https://posthog.com/) and create an account.
  </Step>

  <Step>
    After you create your account, you'll see this screen.

    <Frame>
      <img src="https://mintcdn.com/shipmobilefast-51a499dc/rNBXOQ08cKXtmr3A/images/posthog/posthog1.png?fit=max&auto=format&n=rNBXOQ08cKXtmr3A&q=85&s=d9ed893dc27409def564e7c1c0141d86" alt="PostHog Create Project" className="rounded-2xl" width="835" height="890" data-path="images/posthog/posthog1.png" />
    </Frame>

    Click the `Product Analytics` button.
  </Step>

  <Step>
    After you click the `Product Analytics` button, you'll see this screen and pick the `React Native` option.

    <Frame>
      <img src="https://mintcdn.com/shipmobilefast-51a499dc/rNBXOQ08cKXtmr3A/images/posthog/posthog2.png?fit=max&auto=format&n=rNBXOQ08cKXtmr3A&q=85&s=62e3a6f95326eb7c31469943f8ee8108" alt="PostHog Product Analytics" className="rounded-2xl" width="1034" height="952" data-path="images/posthog/posthog2.png" />
    </Frame>
  </Step>

  <Step>
    Copy the `apiKey` and host.

    <Frame>
      <img src="https://mintcdn.com/shipmobilefast-51a499dc/rNBXOQ08cKXtmr3A/images/posthog/posthog3.png?fit=max&auto=format&n=rNBXOQ08cKXtmr3A&q=85&s=aaa7930f8cf0bbd8473ea40808ad118e" alt="PostHog apiKey and host" className="rounded-2xl" width="724" height="479" data-path="images/posthog/posthog3.png" />
    </Frame>
  </Step>

  <Step>
    Go to the `.env` file and add this:

    ```
    EXPO_PUBLIC_POSTHOG_API_KEY=your-posthog-api-key-here
    EXPO_PUBLIC_POSTHOG_HOST=your-posthog-host-here
    ```
  </Step>

  <Step>
    Then go to the `app/_layout.tsx` file and add this:

    ```tsx app/_layout.tsx theme={null}
    import { PostHogProvider } from 'posthog-react-native';
    import { posthog } from '@/services/posthog/posthogConfig';
    ```
  </Step>

  <Step>
    And add this to the bottom of the `app/_layout.tsx` file:

    ```tsx app/_layout.tsx theme={null}
    const RootLayout = () => {
    return (
      <Provider store={store}>
        {/* If you want to use Posthog, add the following lines 👇 */}
        <PostHogProvider client={posthog}>
        <AuthProvider>
         {...}
        </AuthProvider>
        </PostHogProvider> {/* 👈 */}
      </Provider>
      );
    };
    ```
  </Step>

  <Step>
    <Info>
      This is optional, but if you want to session replay, you can uncomment some of the following lines:
    </Info>

    As a final step, go to the `@services/posthog/posthogConfig.ts` file and you can uncomment some of the following lines.
  </Step>

  <Step>
    That's it. You are done. Capture even the Imagination!
  </Step>
</Steps>
