
Posthog Analytics
Wire PostHog event tracking, user identification, feature flags, and decision-focused dashboards without tracking noise.
Overview
Posthog-analytics is an agent skill most often used in Grow (also Build integrations) that implements PostHog event tracking, identification, feature flags, and dashboards for decision-ready product analytics.
Install
npx skills add https://github.com/alinaqi/claude-bootstrap --skill posthog-analyticsWhat is this skill?
- Philosophy-first guidance: measure activation, retention, funnels, and feature usage—not vanity events
- Next.js App Router install pattern with posthog-js init and identified-only person profiles
- Manual pageview/pageleave capture for SPA-friendly routing control
- Feature flags and project dashboards tied to PostHog product analytics docs
- Links to official PostHog docs for events, flags, and dashboard setup
Adoption & trust: 655 installs on skills.sh; 691 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need trustworthy product analytics and flags in your app but lack a focused PostHog setup that avoids over-tracking and SPA pitfalls.
Who is it for?
Solo builders shipping a Next.js or web SaaS who want PostHog wired with activation, funnel, and feature-usage events—not a firehose.
Skip if: Teams that only need server-side-only analytics with no client SDK, or products with no user-facing app where PostHog’s web SDK does not apply.
When should I use this skill?
When adding analytics, feature flags, or event tracking with PostHog
What do I get? / Deliverables
You get a PostHog integration pattern with intentional events, identification, flags, and dashboards that answer specific growth questions.
- PostHog client init module
- Event and identification conventions
- Feature-flag usage pattern
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
PostHog is installed to answer growth questions—activation, retention, funnels, and feature usage—so the canonical shelf is Grow even though SDK work happens earlier. Analytics subphase matches product measurement and dashboards that inform what to ship next, which is the skill’s stated philosophy.
Where it fits
Install posthog-js and init with capture_pageview false before your first production deploy.
Define acquisition and activation events before you push traffic from a launch post.
Build funnels and dashboards to see where signups stall after a pricing change.
How it compares
Use as a structured PostHog implementation guide instead of scattering one-off tracking snippets across chat sessions.
Common Questions / FAQ
Who is posthog-analytics for?
Indie and solo builders adding PostHog to a web product who want events, flags, and dashboards that support real product decisions.
When should I use posthog-analytics?
During Build when integrating the SDK, at Launch when defining core events, and in Grow when tuning funnels, retention, and feature-flag rollouts.
Is posthog-analytics safe to install?
Review the Security Audits panel on this Prism page before piping production keys into your repo; the skill references network calls to PostHog hosts.
SKILL.md
READMESKILL.md - Posthog Analytics
# PostHog Analytics Skill For implementing product analytics with PostHog - event tracking, user identification, feature flags, and project-specific dashboards. **Sources:** [PostHog Docs](https://posthog.com/docs) | [Product Analytics](https://posthog.com/docs/product-analytics) | [Feature Flags](https://posthog.com/docs/feature-flags) --- ## Philosophy **Measure what matters, not everything.** Analytics should answer specific questions: - Are users getting value? (activation, retention) - Where do users struggle? (funnels, drop-offs) - What features drive engagement? (feature usage) - Is the product growing? (acquisition, referrals) Don't track everything. Track what informs decisions. --- ## Installation ### Next.js (App Router) ```bash npm install posthog-js ``` ```typescript // lib/posthog.ts import posthog from 'posthog-js'; export function initPostHog() { if (typeof window !== 'undefined' && !posthog.__loaded) { posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, { api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || 'https://us.i.posthog.com', person_profiles: 'identified_only', // Only create profiles for identified users capture_pageview: false, // We'll handle this manually for SPA capture_pageleave: true, loaded: (posthog) => { if (process.env.NODE_ENV === 'development') { posthog.debug(); } }, }); } return posthog; } export { posthog }; ``` ```typescript // app/providers.tsx 'use client'; import { useEffect } from 'react'; import { usePathname, useSearchParams } from 'next/navigation'; import { initPostHog, posthog } from '@/lib/posthog'; export function PostHogProvider({ children }: { children: React.ReactNode }) { const pathname = usePathname(); const searchParams = useSearchParams(); useEffect(() => { initPostHog(); }, []); // Track pageviews useEffect(() => { if (pathname) { let url = window.origin + pathname; if (searchParams.toString()) { url += `?${searchParams.toString()}`; } posthog.capture('$pageview', { $current_url: url }); } }, [pathname, searchParams]); return <>{children}</>; } ``` ```typescript // app/layout.tsx import { PostHogProvider } from './providers'; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( <html lang="en"> <body> <PostHogProvider> {children} </PostHogProvider> </body> </html> ); } ``` ### React (Vite/CRA) ```typescript // src/posthog.ts import posthog from 'posthog-js'; posthog.init(import.meta.env.VITE_POSTHOG_KEY, { api_host: import.meta.env.VITE_POSTHOG_HOST || 'https://us.i.posthog.com', person_profiles: 'identified_only', }); export { posthog }; ``` ```typescript // src/main.tsx import { PostHogProvider } from 'posthog-js/react'; import { posthog } from './posthog'; ReactDOM.createRoot(document.getElementById('root')!).render( <PostHogProvider client={posthog}> <App /> </PostHogProvider> ); ``` ### Python (FastAPI/Flask) ```bash pip install posthog ``` ```python # analytics/posthog_client.py import posthog from functools import lru_cache @lru_cache() def get_posthog(): posthog.project_api_key = os.environ["POSTHOG_API_KEY"] posthog.host = os.environ.get("POSTHOG_HOST", "https://us.i.posthog.com") posthog.debug = os.environ.get("ENV") == "development" return posthog # Usage def track_event(user_id: str, event: str, properties: dict = None): ph = get_posthog() ph.capture( distinct_id=user_id, event=event, properties=properties or {} ) def identify_user(user_id: str, properties: dict): ph = get_posthog() ph.identify(user_id, properti