# PostHog

> Learn how to add PostHog analytics to your Fern documentation. Configure your PostHog API key and custom endpoint.

Integrate PostHog to track user behavior and analytics in your documentation, including page views, feature usage, and user interactions.

<Steps>
  <Step title="Get your PostHog API key">
    You can find your PostHog API key under your [project settings](https://us.posthog.com/settings/project).
  </Step>

  <Step title="Add PostHog to `docs.yml`">
    In your `docs.yml` file, add your PostHog configuration:

    <CodeBlock title="docs.yml">
      ```yaml
      analytics:
        posthog:
          api-key: ${POSTHOG_API_KEY}
      ```
    </CodeBlock>
  </Step>

  <Step title="(Optional) Configure a custom endpoint">
    If you use a custom PostHog endpoint, add it to your configuration:

    <CodeBlock title="docs.yml">
      ```yaml {4}
      analytics:
        posthog:
          api-key: ${POSTHOG_API_KEY}
          endpoint: ${POSTHOG_API_HOST} # e.g. https://analytics.example.com or https://eu.i.posthog.com
      ```
    </CodeBlock>
  </Step>
</Steps>