posthog-core-workflow-a
Implement PostHog product analytics: event capture, user identification, group analytics, and property management using posthog-js and posthog-node. Trigger: "posthog analytics", "capture events", "track users posthog", "posthog identify", "posthog group analytics", "product analytics".
Best use case
posthog-core-workflow-a is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Implement PostHog product analytics: event capture, user identification, group analytics, and property management using posthog-js and posthog-node. Trigger: "posthog analytics", "capture events", "track users posthog", "posthog identify", "posthog group analytics", "product analytics".
Teams using posthog-core-workflow-a should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/posthog-core-workflow-a/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How posthog-core-workflow-a Compares
| Feature / Agent | posthog-core-workflow-a | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Implement PostHog product analytics: event capture, user identification, group analytics, and property management using posthog-js and posthog-node. Trigger: "posthog analytics", "capture events", "track users posthog", "posthog identify", "posthog group analytics", "product analytics".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
SKILL.md Source
# PostHog Core Workflow A — Product Analytics
## Overview
Primary PostHog workflow covering event capture, user identification, group analytics, and person properties. This is the foundation for all PostHog analytics: capturing what users do, linking events to identified users, and grouping users by company/team for B2B analytics.
## Prerequisites
- Completed `posthog-install-auth` setup
- `posthog-js` (browser) and/or `posthog-node` (server) installed
- Project API key (`phc_...`) configured
## Instructions
### Step 1: Define Event Taxonomy
```typescript
// src/analytics/events.ts
// Define all events as typed constants for consistency
export const EVENTS = {
// User lifecycle
USER_SIGNED_UP: 'user_signed_up',
USER_LOGGED_IN: 'user_logged_in',
USER_ONBOARDING_COMPLETED: 'user_onboarding_completed',
// Core product actions
FEATURE_USED: 'feature_used',
ITEM_CREATED: 'item_created',
ITEM_UPDATED: 'item_updated',
ITEM_DELETED: 'item_deleted',
SEARCH_PERFORMED: 'search_performed',
EXPORT_COMPLETED: 'export_completed',
// Revenue events
SUBSCRIPTION_STARTED: 'subscription_started',
SUBSCRIPTION_UPGRADED: 'subscription_upgraded',
SUBSCRIPTION_CANCELED: 'subscription_canceled',
PAYMENT_COMPLETED: 'payment_completed',
} as const;
// Standard property schema for consistency across events
interface BaseProperties {
source?: 'web' | 'mobile' | 'api' | 'webhook';
plan_tier?: 'free' | 'pro' | 'enterprise';
duration_ms?: number;
}
```
### Step 2: Capture Events (Browser)
```typescript
import posthog from 'posthog-js';
import { EVENTS } from './events';
// Custom event with properties
posthog.capture(EVENTS.ITEM_CREATED, {
item_type: 'document',
source: 'web',
plan_tier: 'pro',
});
// Timed event (measure duration)
const start = performance.now();
await doExpensiveOperation();
posthog.capture(EVENTS.EXPORT_COMPLETED, {
format: 'csv',
row_count: 1500,
duration_ms: Math.round(performance.now() - start),
});
// Pageview with custom properties (if capture_pageview: false)
posthog.capture('$pageview', {
page_title: document.title,
referrer: document.referrer,
});
```
### Step 3: Identify Users and Set Properties
```typescript
// After user logs in — links anonymous events to this user
posthog.identify('user-456', {
// $set properties (persist, overwrite on change)
email: 'jane@acme.com',
name: 'Jane Smith',
plan: 'enterprise',
signup_date: '2025-06-15',
});
// Update properties later without re-identifying
posthog.people.set({
last_active: new Date().toISOString(),
total_items: 42,
});
// Set properties only if not already set ($set_once)
posthog.people.set_once({
first_seen: new Date().toISOString(),
original_referrer: document.referrer,
});
// Unset properties
posthog.people.unset(['deprecated_field']);
// Reset on logout (clears distinct_id, starts new anonymous session)
posthog.reset();
```
### Step 4: Group Analytics (B2B Company Tracking)
```typescript
// Associate user with a company group
posthog.group('company', 'company-789', {
name: 'Acme Corp',
industry: 'SaaS',
plan: 'enterprise',
employee_count: 150,
arr: 250000,
});
// Events now automatically include company context
posthog.capture(EVENTS.FEATURE_USED, {
feature_name: 'bulk-export',
});
// This event is attributed to both user-456 AND company-789
// Multiple group types
posthog.group('team', 'team-alpha', { name: 'Alpha Team' });
```
### Step 5: Server-Side Event Capture (posthog-node)
```typescript
import { PostHog } from 'posthog-node';
const posthog = new PostHog(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
host: 'https://us.i.posthog.com',
});
// Server-side capture (e.g., in API route or webhook handler)
function trackServerEvent(userId: string, event: string, properties?: Record<string, any>) {
posthog.capture({
distinctId: userId,
event,
properties: {
...properties,
source: 'api',
},
});
}
// Identify with server-side properties
posthog.identify({
distinctId: 'user-456',
properties: {
subscription_status: 'active',
mrr: 99,
},
});
// Group identify from server
posthog.groupIdentify({
groupType: 'company',
groupKey: 'company-789',
properties: {
plan: 'enterprise',
total_seats: 50,
},
});
// CRITICAL: Flush in serverless/edge functions
await posthog.flush();
```
### Step 6: Create Annotations for Context
```bash
set -euo pipefail
# Mark a deployment or product change in PostHog
curl -X POST "https://app.posthog.com/api/projects/$POSTHOG_PROJECT_ID/annotations/" \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "v2.5.0 deployed — new checkout flow",
"date_marker": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",
"scope": "project"
}'
```
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| Events not appearing | `posthog.init` not called | Ensure init runs before any capture |
| Anonymous/identified split | Different `distinct_id` across platforms | Use consistent user ID from your auth system |
| Group data missing | `posthog.group()` not called | Call `group()` before capture for group attribution |
| Server events lost | No `flush()` in serverless | Always call `await posthog.flush()` before response |
| Properties not updating | Using `$set_once` for mutable data | Use `posthog.people.set()` for values that change |
## Output
- Typed event taxonomy for consistent tracking
- Browser event capture with user identification
- B2B group analytics linking users to companies
- Server-side event capture with proper flushing
- Annotations marking deployments and product changes
## Resources
- [Capture Events](https://posthog.com/docs/product-analytics/capture-events)
- [Identifying Users](https://posthog.com/docs/product-analytics/identify)
- [Group Analytics](https://posthog.com/docs/product-analytics/group-analytics)
- [Annotations API](https://posthog.com/docs/api/annotations)
## Next Steps
For feature flags and experiments, see `posthog-core-workflow-b`.Related Skills
calendar-to-workflow
Converts calendar events and schedules into Claude Code workflows, meeting prep documents, and standup notes. Use when the user mentions calendar events, meeting prep, standup generation, or scheduling workflows. Trigger with phrases like "prep for my meetings", "generate standup notes", "create workflow from calendar", or "summarize today's schedule".
workhuman-core-workflow-b
Workhuman core workflow b for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman core workflow b".
workhuman-core-workflow-a
Workhuman core workflow a for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman core workflow a".
wispr-core-workflow-b
Wispr Flow core workflow b for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr core workflow b".
wispr-core-workflow-a
Wispr Flow core workflow a for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr core workflow a".
windsurf-core-workflow-b
Execute Windsurf's secondary workflow: Workflows, Memories, and reusable automation. Use when creating reusable Cascade workflows, managing persistent memories, or automating repetitive development tasks. Trigger with phrases like "windsurf workflow", "windsurf automation", "windsurf memories", "cascade workflow", "windsurf slash command".
windsurf-core-workflow-a
Execute Windsurf's primary workflow: Cascade Write mode for multi-file agentic coding. Use when building features, refactoring across files, or performing complex code tasks. Trigger with phrases like "windsurf cascade write", "windsurf agentic coding", "windsurf multi-file edit", "cascade write mode", "windsurf build feature".
webflow-core-workflow-b
Execute Webflow secondary workflows — Sites management, Pages API, Forms submissions, Ecommerce (products/orders/inventory), and Custom Code via the Data API v2. Use when managing sites, reading pages, handling form data, or working with Webflow Ecommerce products and orders. Trigger with phrases like "webflow sites", "webflow pages", "webflow forms", "webflow ecommerce", "webflow products", "webflow orders".
webflow-core-workflow-a
Execute the primary Webflow workflow — CMS content management: list collections, CRUD items, publish items, and manage content lifecycle via the Data API v2. Use when working with Webflow CMS collections and items, managing blog posts, team members, or any dynamic content. Trigger with phrases like "webflow CMS", "webflow collections", "webflow items", "create webflow content", "manage webflow CMS", "webflow content management".
veeva-core-workflow-b
Veeva Vault core workflow b for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva core workflow b".
veeva-core-workflow-a
Veeva Vault core workflow a for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva core workflow a".
vastai-core-workflow-b
Execute Vast.ai secondary workflow: multi-instance orchestration, spot recovery, and cost optimization. Use when running distributed training, handling spot preemption, or optimizing GPU spend across multiple instances. Trigger with phrases like "vastai distributed training", "vastai spot recovery", "vastai multi-gpu", "vastai cost optimization".