Docusaurus v2 Integration

Install

yarn add posthog-docusaurus

or

npm install --save posthog-docusaurus

How to use

// in docusaurus.config.js
module.exports = {
  plugins: ["posthog-docusaurus"],
  themeConfig: {
    posthog: {
      apiKey: "YOURAPIKEY",
      appUrl: "https://app.posthog.com",  // optional
      enableInDevelopment: false  // optional
    }
  }
};

This will automatically start tracking pageviews, clicks and more.

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