analytics-integration

Integrate PostHog analytics into Next.js apps for page-view and event tracking.

1|1|Updated Apr 13, 2026
One-click install
npx skills add https://github.com/Cheggin/request-for-startups --skill analytics-integration-cheggin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: analytics-integration
Source: https://github.com/Cheggin/request-for-startups/tree/main/skills/analytics-integration
Command: npx skills add https://github.com/Cheggin/request-for-startups --skill analytics-integration-cheggin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Set up PostHog product analytics in a Next.js app to track user behavior, measure conversions, and run experiments.

Core Features & Use Cases

  • Install posthog-js and initialize analytics in the app layout or provider with the project API key from environment variables.
  • Auto-capture page views and link user identities to the auth system so events are attributable to authenticated users.
  • Create dashboards, configure read-only API access, and run A/B tests using feature flags to validate experiments.

Quick Start

Install posthog-js, initialize the analytics provider in your Next.js app, and verify events appear in your PostHog dashboards.

Frequently Asked Questions about analytics-integration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I integrate PostHog analytics into a Next.js app?

To integrate PostHog analytics, install the posthog-js library, initialize an analytics provider with your project API key from environment variables, and wire it to Next.js router events to auto-track page views.

Can I run A/B tests in Next.js using PostHog feature flags?

Yes, you can run A/B tests in Next.js by configuring PostHog feature flags to validate experiments, allowing you to test variations and measure conversion outcomes directly within your application.

What is needed to track authenticated user behavior in Next.js?

Tracking authenticated user behavior requires the posthog-js library initialized in your app layout, where you link user identities to your auth system so events are attributable to specific authenticated users.

Do I need environment variables for PostHog event tracking?

Yes, PostHog event tracking requires a project API key stored in environment variables to securely initialize the posthog-js library and send analytics data to your dashboards.

How does auto-capture page view tracking work with the Next.js router?

Auto-capture page view tracking works by wiring the PostHog analytics provider to Next.js router events, automatically logging navigation actions without requiring manual event triggers on each page.