> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiJhOTA2ZWM0MS1iMGM3LTQxMjctYTEyNi0wNmJmMmNkNDI3YzQiLCJleHAiOjE3NzgyNzA3NjMsImlhdCI6MTc3ODI3MDQ2M30.eQsEFcyeA5XbqQHuZ3I4Ci4xjrzcmfsk9gQoE_Rsl6Q
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# PostHog

> 学习如何向您的 Fern 文档添加 PostHog 分析。配置您的 PostHog API 密钥和自定义端点。

集成 PostHog 来跟踪您文档中的用户行为和分析数据，包括页面浏览量、功能使用情况和用户交互。

<Steps>
  <Step title="获取您的 PostHog API 密钥">
    您可以在[项目设置](https://us.posthog.com/settings/project)下找到您的 PostHog API 密钥。
  </Step>

  <Step title="将 PostHog 添加到 `docs.yml`">
    在您的 `docs.yml` 文件中，添加您的 PostHog 配置：

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

  <Step title="（可选）配置自定义端点">
    如果您使用自定义 PostHog 端点，请将其添加到您的配置中：

    <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>