Analytics
We use PostHog to measure how users interact with SlideSpeak. PostHog helps us understand user behavior, identify friction points, and make data-driven decisions about product improvements.
View analytics data in the PostHog dashboard.
What Events to Track
Section titled “What Events to Track”Track user behavior events that provide meaningful insights:
Track these:
- User actions (clicks, form submissions, feature usage)
- Feature adoption (new features being used)
- Business metrics (subscriptions, downloads, shares)
- Error events (for debugging and monitoring)
- User journey milestones (onboarding completion, first presentation created)
Avoid tracking:
- High-frequency events like text editing or typing
- Events that fire on every keystroke or mouse movement
- Events that don’t provide actionable insights
Tracking too many events increases costs and makes it harder to find meaningful patterns. Focus on events that represent user intent and meaningful actions.
Client-Side Tracking
Section titled “Client-Side Tracking”Track events directly from client components using the centralized track service.
Tracking Events
Section titled “Tracking Events”Use the track service in your components:
import { track } from '@/services/tracking';
const MyComponent = () => { const handleClick = () => { track.presentation.downloadClicked(presentationId); };
return <button onClick={handleClick}>Download</button>;};Adding New Events
Section titled “Adding New Events”Add new tracking functions to src/services/tracking.ts:
import posthog from 'posthog-js';
export const track = { myFeature: { actionCompleted: (data: MyDataType) => { posthog.capture('my_feature_action_completed', { ...data }); }, },};Server-Side Tracking
Section titled “Server-Side Tracking”Track events from server-side code (server functions, API routes, background jobs).
Tracking Events
Section titled “Tracking Events”Use the server PostHog client:
import { getPostHogServerClient } from '@/lib/posthog';
const posthog = getPostHogServerClient();
posthog?.capture({ distinctId: userEmail, event: 'user_created', properties: { email: userEmail, name: userName, },});
await posthog?.shutdown();Important: Always call shutdown() after tracking events to ensure they’re sent before the process exits.
User Properties
Section titled “User Properties”Set user properties using $set and $set_once:
$set: Updates user properties (overwrites existing)$set_once: Sets user properties only if not already set
posthog?.capture({ distinctId: email, event: 'subscription_changed', properties: { $set: { subscription: 'PREMIUM' }, $set_once: { created_at: new Date().toISOString() }, },});Best Practices
Section titled “Best Practices”- Use the tracking service: Centralize event tracking in
src/services/tracking.tsrather than calling PostHog directly - Include relevant context: Add properties that help understand the event (duration, success status, user context)
- Avoid sensitive data: Don’t track passwords, API keys, or other sensitive information
- Call shutdown on server: Always call
shutdown()after server-side tracking to ensure events are sent - Use consistent naming: Use underscores for event names (e.g.,
presentation_generated). Note that some older events may still use kebab-case.