PostHog 是一款开源的产品分析平台,它允许您自行托管数据,从而完全掌控数据隐私和安全。通过会话记录、功能标记和 A/B 测试等功能,您可以深入了解用户行为,优化产品性能。
特性
- 手动指定事件或使用自动捕获快速入门
- 使用现成的可视化分析数据,或使用 SQL 自己分析
- 使用我们的 GA4 替代方案单独跟踪网站访问者
- 仅捕获您想要跟踪的人员的属性,在不跟踪时节省资金
- 通过捕获会话回放、控制台日志和网络监控收集见解
- 使用自动分析性能的实验改进您的产品
- 使用功能标志安全地将功能推出给选定的用户或群体
- 向特定群组的用户发送完全可定制的调查
- 使用 PostHog CDP 连接到外部服务并管理数据流
安装
复制下面的代码段,将
<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys getNextSurveyStep onSessionId".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('<ph_project_api_key>', {api_host: 'https://us.i.posthog.com', person_profiles: 'identified_only'})
</script>
添加代码段后,PostHog 会自动捕获 $pageview
和其他事件,例如按钮点击。