Analytics

Track user behavior, measure feature adoption, and understand product usage with a unified analytics API. Swap providers without changing application code.

trackingeventsproductusage

Providers

PostHog

Open-source product analytics with session replay and feature flags

posthog-node
POSTHOG_API_KEYPOSTHOG_HOST

Mixpanel

Event-based product analytics with funnel and retention analysis

mixpanel
MIXPANEL_TOKEN

Amplitude

Product analytics with behavioral cohorting and experimentation

@amplitude/analytics-node
AMPLITUDE_API_KEY

Usage

Track events

Send analytics events through the unified API

import { analytics } from '@/lib/analytics'

// Track a custom event
analytics.track('button_clicked', {
  buttonId: 'signup-cta',
  page: '/landing',
})

// Identify a user
analytics.identify(userId, {
  plan: 'pro',
  signupDate: new Date(),
})

Get Started

Add analytics to your Primstack project with a single command:

prim analytics init