integration-javascript_web — Claude Code skill: setup and usage
integration-javascript_web guides client-side PostHog setup in browser JavaScript apps using posthog-js.
MIT 125 installs ★ 80 updated 2026-10-24
npx skills add PostHog/skills --skill integration-javascript_web -a claude-codeWhat integration-javascript_web does
This skill directs the integration through four distinct stages: begin, edit, revise, and conclude. It enforces standard client patterns: keeping PostHog credentials in environment variables, preserving default autocapture for forms and clicks, and executing posthog.init() before invoking other SDK calls.
The library runs strictly in web browsers. Server execution will fail, because backend JavaScript requires posthog-node. When a backend exists, the skill instructs passing X-POSTHOG-DISTINCT-ID and X-POSTHOG-SESSION-ID headers to align tracking across stacks.
Personal data handling follows a strict boundary. Sensitive user fields belong solely in posthog.identify(), keeping them entirely out of posthog.capture() event payloads. It also sets up posthog.reset() on logout to unlink subsequent events.
What it helps with
- embed posthog-js into a client-side JavaScript project
- set up user identification on login and page refreshes
- pass session and distinct IDs to the backend via headers
- add PostHog error monitoring around API calls
Example prompts for the agent
- Add PostHog tracking to this web app using posthog-js
- Implement posthog.identify on user authentication and posthog.reset on logout
- Set up error tracking with PostHog around the main API endpoints
How to install integration-javascript_web
1Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_web -a claude-code2Manually: put the files in place
~/.claude/skills/integration-javascript_web/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/integration-javascript_web/
1Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_web -a codex2Manually: put the files in place
.agents/skills/integration-javascript_web/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_web -a cursor2Manually: put the files in place
.cursor/skills/integration-javascript_web/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install PostHog/skills skills/posthog/all/skills/integration-javascript_web2Manually: put the files in place
.github/skills/integration-javascript_web/SKILL.md1Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_web -a gemini-cli2Platform CLI
gemini skills install https://github.com/PostHog/skills --path skills/posthog/all/skills/integration-javascript_webManually: put the files in place
.devin/skills/integration-javascript_web/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add PostHog/skills --skill integration-javascript_web -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about integration-javascript_web
How to install integration-javascript_web in Claude Code?
Run npx skills add PostHog/skills --skill integration-javascript_web -a claude-code in your terminal.
What does integration-javascript_web do?
It provides workflow steps and strict rules for embedding PostHog browser analytics into web frontends.
Can posthog-js be imported into Node.js backend files?
No, posthog-js is browser-only. Server environments require the posthog-node package instead.
Source text
SKILL.md · MIT
---
name: integration-javascript_web
description: >-
PostHog integration for client-side web JavaScript applications using
posthog-js
metadata:
author: PostHog
version: 1.9.4
---
# PostHog integration for JavaScript Web
This skill helps you add PostHog analytics to JavaScript Web applications.
## Workflow
Follow these steps in order to complete the integration:
1. `basic-integration-1.0-begin.md` - PostHog Setup - Begin ← **Start here**
2. `basic-integration-1.1-edit.md` - PostHog Setup - Edit
3. `basic-integration-1.2-revise.md` - PostHog Setup - Revise
4. `basic-integration-1.3-conclude.md` - PostHog Setup - Conclusion
## Reference files
- `references/js.md` - JavaScript web - docs
- `references/posthog-js.md` - PostHog JavaScript web SDK
- `references/identify-users.md` - Identify users - docs
- `references/basic-integration-1.0-begin.md` - PostHog setup - begin
- `references/basic-integration-1.1-edit.md` - PostHog setup - edit
- `references/basic-integration-1.2-revise.md` - PostHog setup - revise
- `references/basic-integration-1.3-conclude.md` - PostHog setup - conclusion
The example project shows the target implementation pattern. Consult the documentation for API details.
## Key principles
- **Environment variables**: Always use environment variables for PostHog keys. Never hardcode them.
- **Minimal changes**: Add PostHog code alongside existing integrations. Don't replace or restructure existing code.
- **Match the example**: Your implementation should follow the example project's patterns as closely as possible.
## Framework guidelines
- Remember that source code is available in the node_modules directory
- Check package.json for type checking or build scripts to validate changes
- posthog-js is the JavaScript SDK package name
- posthog.init() MUST be called before any other PostHog methods (capture, identify, etc.)
- posthog-js is browser-only — do NOT import it in Node.js or server-side contexts (use posthog-node instead)
- Autocapture is ON by default with posthog-js (tracks clicks, form submissions, pageviews). Do NOT disable autocapture unless the user explicitly requests it.
- NEVER send PII in posthog.capture() event properties — no emails, full names, phone numbers, physical addresses, IP addresses, or user-generated content
- PII belongs in posthog.identify() person properties (email, name, role), NOT in capture() event properties
- Call posthog.identify(userId, { email, name, role }) on login AND on page refresh if the user is already logged in
- Call posthog.reset() on logout to unlink future events from the current user
- For SPAs without a framework router, capture pageviews with posthog.capture($pageview) or use the capture_pageview history_change option in init for History API routing
## Identifying users
Identify users during login and signup events. Refer to the example code and documentation for the correct identify pattern for this framework. If both frontend and backend code exist, pass the client-side session and distinct ID using `X-POSTHOG-DISTINCT-ID` and `X-POSTHOG-SESSION-ID` headers to maintain correlation.
## Error tracking
Add PostHog error tracking to relevant files, particularly around critical user flows and API boundaries.
© PostHog · MIT · PostHog/skills