Now 100x Faster

Read the latest from Gatsby CTO Kyle Mathews Re-introducing Gatsby, a Reactive Site Generator

ContactSign Up for Free
Community Plugin
View plugin on GitHub

gatsby-plugin-posthog-analytics

A simple gatsby plugin to add posthog analytics to your site. Automatically tracks all the pageviews and clicks.

Install

yarn add gatsby-plugin-posthog-analytics

or

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

How to use

// 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
      },
    },
  ],
}
© 2022 Gatsby, Inc.