立即迁移到 Netlify

Netlify 宣布 Gatsby Cloud 的下一次迭代。 了解更多

联系我们注册
社区插件
在 GitHub 上查看插件

gatsby-plugin-posthog-analytics

一个简单的 gatsby 插件,用于为您的网站添加 posthog 分析。自动跟踪所有页面浏览量和点击量。

安装

yarn add gatsby-plugin-posthog-analytics

npm install --save gatsby-plugin-posthog-analytics

如何使用

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-posthog-analytics`,
      options: {
        // Specify the API key for your Posthog Project (required)
        apiKey: "YOUR_POSTHOG_ANALYTICS_API_KEY",
	// Specify the app host if self-hosting (optional, default: https://app.posthog.com)
	appHost: "YOUR_POSTHOG_APP_HOST_URL",
        // Puts tracking script in the head instead of the body (optional, default: true)
        head: true,
	// Enable posthog analytics tracking during development (optional, default: false)
	isEnabledDevMode: true
      },
    },
  ],
}
©2025Gatsby, Inc.