Analytics tracking

From tinh2/skills-hub-registry · View interactive version

Analytics tracking is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Set up production-ready event tracking with Amplitude, Mixpanel, PostHog, or GA4. Triggers: you need analytics, event tracking, user tracking, product analytics, usage metrics.

How to use this skill

Skill file

You are in AUTONOMOUS MODE. Do NOT ask questions. Detect everything from the codebase and proceed.

PURPOSE:

Set up production-ready analytics event tracking. Auto-detect the project's framework and the

requested analytics provider. Install the SDK, create a framework-agnostic analytics service,

define a core event taxonomy, and instrument key user flows.

TASK:

$ARGUMENTS

============================================================

PHASE 0: DETECTION

============================================================

  1. FRAMEWORK DETECTION -- scan the project root to identify the tech stack:
  1. PROVIDER DETECTION -- determine analytics provider from $ARGUMENTS or existing config:
  1. EXISTING ANALYTICS CHECK -- search for existing analytics wrappers:

============================================================

PHASE 1: SDK INSTALLATION

============================================================

Install the correct SDK for the detected provider and framework:

AMPLITUDE:

MIXPANEL:

POSTHOG:

GA4:

After installing:

============================================================

PHASE 2: ANALYTICS SERVICE

============================================================

Create a framework-agnostic analytics service wrapper. This abstraction lets the team swap

providers without touching feature code.

FILE LOCATION:

THE SERVICE MUST EXPOSE:

init(config) -- Initialize the SDK with API key and options.

identify(userId, properties) -- Set the current user identity and traits.

track(eventName, properties) -- Track a named event with arbitrary properties.

page(name, properties) -- Track a page/screen view.

reset() -- Clear the user identity on logout.

setUserProperties(properties) -- Update user-level properties without an event.

group(groupType, groupId) -- Associate user with a group/company (if supported).

flush() -- Force-send queued events (for server-side or before app close).

IMPLEMENTATION REQUIREMENTS:

============================================================

PHASE 3: EVENT TAXONOMY

============================================================

Create a typed event catalog. This prevents typo-driven event sprawl.

FILE: src/lib/analytics-events.ts (or framework equivalent)

CORE EVENTS (define all of these):

page_view -- { page_name, referrer?, duration_ms? }

sign_up -- { method: "email" | "google" | "github" | "apple", referral_source? }

login -- { method, success: boolean }

logout -- {}

purchase -- { item_id, item_name, price, currency, quantity }

subscription_start -- { plan, billing_period, trial: boolean }

feature_used -- { feature_name, context? }

search -- { query, results_count, filters? }

error_occurred -- { error_type, error_message, screen?, severity }

cta_clicked -- { cta_name, location, destination? }

onboarding_step -- { step_number, step_name, completed: boolean }

share -- { content_type, method }

feedback_submitted -- { rating?, comment?, screen? }

RULES:

============================================================

PHASE 4: INSTRUMENTATION

============================================================

Wire tracking into the application's key flows:

  1. PAGE VIEWS:
  1. USER IDENTIFICATION:
  1. KEY FLOW INSTRUMENTATION:
  1. SERVER-SIDE EVENTS (if backend detected):

============================================================

PHASE 5: PRIVACY AND COMPLIANCE

============================================================

  1. DNT (Do Not Track):
  1. COOKIE CONSENT:
  1. GDPR / DATA MINIMIZATION:
  1. APP STORE COMPLIANCE (mobile):

============================================================

PHASE 6: VALIDATION

============================================================

  1. Run the project's build/compile step -- fix any errors.
  2. Run existing tests -- fix any failures caused by analytics integration.
  3. Verify the analytics service can be imported and instantiated without errors.
  4. If a dev server is available, confirm no console errors from the analytics SDK.

============================================================

SELF-EVOLUTION TELEMETRY

============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

Entry format:

### /analytics-tracking — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}

Only log if the memory directory exists. Skip silently if not found.

Keep entries concise — /evolve will parse these for skill improvement signals.

============================================================

DO NOT

============================================================

============================================================

SELF-HEALING VALIDATION (max 3 iterations)

============================================================

After completing the integration, validate:

  1. Run the project's test suite to verify the integration works end-to-end.
  2. Run build/compile to confirm no breakage.
  3. Verify the integration responds correctly (health checks, test calls, smoke tests).
  4. If failures occur, diagnose from error output and apply minimal fixes.
  5. Repeat up to 3 iterations.

IF STILL FAILING after 3 iterations:

============================================================

OUTPUT

============================================================

Analytics Tracking Setup

NEXT STEPS:

After analytics tracking is set up:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.