astro-posthog

Posthog integration for Astro


Keywords
astro-integration, astro-component, posthog, analytics, tracking, astro, integration, withastro
License
CNRI-Python-GPL-Compatible
Install
npm install astro-posthog@1.0.2

Documentation

Posthog + Astro Integration

GDRP friendly tracking in your astro app / site 🚀

Installation

Installation using the Astro CLI

Using the Astro CLI is the recommended way to setup integrations in Astro.

# npm
npx astro add astro-posthog

# pnpm
pnpm dlx astro add astro-posthog

Manual Installation

When the automatic setup from Astro is not an option for you, feel free to install the package manually.

# npm
npm install astro-posthog

# pnpm
pnpm add astro-posthog

Usage

import { defineConfig } from 'astro/config';

import posthog from "astro-posthog";

// https://astro.build/config
export default defineConfig({
	integrations: [
		posthog({
			posthogKey: 'phc_your-posthog-key',
			api_host: 'https://eu.i.posthog.com',
			defaults: '2025-05-24',
			person_profiles: 'identified_only',
		}),
	]
});