> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.manicule.dev/zh/llms.txt
> Use this file to discover all available pages before exploring further.
> For every page in one file, fetch https://mintlify.manicule.dev/zh/llms-full.txt (large).
> To search and read these docs as tools, connect the MCP server at https://mintlify.manicule.dev/api/mcp.
> Every agent surface: https://mintlify.manicule.dev/.well-known/llms-manifest.json

# PostHog (/zh/integrations/analytics/posthog)

<!-- agent-signals: reading_time_min: 1 · est_tokens: 355 · updated: 2026-07-31 -->
Related: [Analytics 集成](/zh/integrations/analytics/overview.md), [Amplitude](/zh/integrations/analytics/amplitude.md), [Clarity](/zh/integrations/analytics/clarity.md), [Clearbit](/zh/integrations/analytics/clearbit.md), [Fathom](/zh/integrations/analytics/fathom.md), [Google Analytics 4](/zh/integrations/analytics/google-analytics.md)

> 将 PostHog 集成到你的 Mintlify 文档站点，使用 API 密钥跟踪产品分析、功能使用情况和用户行为。

在你的 `docs.json` 文件中添加以下配置，将 Analytics 数据发送到 PostHog。

只有在自托管 PostHog 时才需要包含 `apiHost`。默认情况下，Mintlify 会通过 `https://ph.mintlify.com` 代理将事件转发到你的 PostHog 项目。

<CodeGroup>
```json title="docs.json 中的 Analytics 选项"
"integrations": {
    "posthog": {
        "apiKey": "YOUR_POSTHOG_PROJECT_API_KEY",
        "apiHost": "optional",
        "sessionRecording": true
    }
}
```

```json title="示例"
"integrations": {
    "posthog": {
        "apiKey": "phc_TXdpocbYTeZVm5VJmMzHTMrCofBQu3e0kN7HGMNGTVW"
    }
}
```
</CodeGroup>

<div id="configuration-options">
  ### 配置选项
</div>

<ParamField path="apiKey" type="string" required>你的 PostHog 项目 API key。必须以 `phc_` 开头。</ParamField>

<ParamField path="apiHost" type="string">你的 PostHog 实例的 URL。仅在自托管 PostHog 时必填。默认为 `https://ph.mintlify.com`（Mintlify 的 PostHog 代理）。</ParamField>

<ParamField path="sessionRecording" type="boolean" default="true">启用或禁用会话录制。将其设为 `false` 可在保持 Analytics 启用的同时禁用会话录制。</ParamField>

<div id="session-recordings">
  ## 会话录制
</div>

在配置 PostHog 时，会话录制默认开启。若要在保持 Analytics 启用的情况下禁用会话录制，请在配置中将 `sessionRecording` 设置为 `false`。

```json title="Disable session recordings"
"integrations": {
    "posthog": {
        "apiKey": "phc_your-key",
        "sessionRecording": false
    }
}
```

在接收会话录制之前，你需要将文档网站的 URL 添加到 PostHog 的“录制授权域名”（Authorized domains for recordings）。添加 URL 的选项位于 PostHog 的项目设置中。
