PishonIQ

Event Tracking

Track custom events and identify users with the Pishoniq SDK

Event tracking is the foundation of product analytics. Pishoniq provides a simple API for capturing user behavior across your application.

Track custom events

Use PishonIQ.track() to record any user action:

PishonIQ.track('button_clicked', {
  button_id: 'signup_cta',
  page: 'homepage',
})

The first argument is the event name. Use consistent snake_case naming. The second argument is an optional properties object for additional context.

Identify users

Associate events with authenticated users to enable funnels, retention, and cohort analysis:

PishonIQ.identify('user_123', {
  email: 'user@company.com',
  plan: 'pro',
})

The SDK persists the user ID and traits in localStorage. Subsequent events are automatically linked to the identified user. Call identify after login or registration.

Track page views

For SPAs or custom routing, track page views explicitly:

PishonIQ.page('/dashboard/analytics')

If you pass no argument, the SDK falls back to window.location.pathname. The auto-capture layer also calls this on every route change when a router is detected.

Reset user state (logout)

When a user signs out, reset the SDK state to start a fresh anonymous session:

PishonIQ._reset() // Testing only

For production, call identify with the new user ID after login — the SDK handles session rebinding automatically.

Recommended events for SaaS

| Event | When to fire | |---|---| | signup_started | User opens the registration form | | signup_completed | User finishes registration | | email_verified | User clicks the verification link | | onboarding_completed | User finishes the onboarding wizard | | checkout_started | User opens checkout | | subscription_created | Payment succeeds | | feature_used | User uses a key feature (with feature_name property) | | invite_sent | User invites a teammate |

Event properties best practices

  • Use consistent keys — button_id, not sometimes buttonId and sometimes btnId.
  • Keep cardinality low — Avoid sending user-generated strings (names, emails) as top-level event properties. Use identify for user traits instead.
  • Include context — Plan tier, acquisition source, A/B test variant, and role make insights more precise.
  • Avoid PII — Hash or omit emails, phone numbers, and free-text fields. Pishoniq stores traits separately from event properties.

Debug mode

Pass debug: true to init() to see SDK activity in the browser console:

PishonIQ.init({
  apiKey: 'pk_live_xxx',
  host: 'https://your-backend.com',
  debug: true,
})

You'll see logs for initialization, event batching, flush attempts, and any network errors.

Next steps

  • AI Insights — How Pishoniq interprets your events and explains anomalies.