Gatsby Integration

This is a community integration that is not maintained by the PostHog core team. Thanks to Ritesh Kadmawala for building it!

Thanks to Ritesh Kadmawala!


yarn add gatsby-plugin-posthog


npm install --save gatsby-plugin-posthog

How to use

// In your gatsby-config.js
module.exports = {
  plugins: [
      resolve: `gatsby-plugin-posthog`,
      options: {
        // Specify the API key for your Posthog Project (required)
        // Specify the app host if self-hosting (optional, default:
        apiHost: "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

This will automatically start tracking pageviews, clicks and more.

For instructions on the JS library itself, see JS integration.

Was this page helpful?