📊 Event Tracking
Learn about automatic events and how to track custom events.
🤖 Automatic Events
Sypnia automatically tracks these events when enabled in your project settings:
| Event | Description | Setting |
|---|---|---|
pageview | Triggered on page load and SPA navigation | track_pageviews |
click | Clicks on links and buttons | track_clicks |
rage_click | 3+ rapid clicks on the same element | track_rage_clicks |
error | JavaScript errors and unhandled rejections | track_errors |
error (HTTP) | HTTP errors (4xx, 5xx responses) | track_http_errors |
performance | Page load timing metrics | track_performance |
web_vital | Core Web Vitals (LCP, CLS) | track_performance |
🎯 Custom Events
Track any custom event using the global Sypnia object:
// Basic event
Sypnia.track('button_clicked');
// Event with properties
Sypnia.track('purchase', {
product_id: 'prod_123',
product_name: 'Pro Plan',
value: 29.99,
currency: 'USD'
});
// Feature usage
Sypnia.track('feature_used', {
feature: 'dark_mode',
action: 'enabled'
});📝 Sypnia.track()
Sypnia.track(eventName: string, properties?: object)| Property | Type | Description |
|---|---|---|
eventName* | string | Name of the event (e.g., "signup", "purchase") |
properties | object | Optional key-value pairs of event metadata |
👤 User Identification
Associate events with a specific user to track them across sessions:
// After user logs in
Sypnia.identify('user_abc123', {
email: 'user@example.com',
name: 'John Doe',
plan: 'pro',
company: 'Acme Inc'
});
// The user ID will be included in all subsequent events⚠️Privacy Note
Only send user data that you have consent to collect. Consider your privacy policy and GDPR/CCPA requirements.
📄 Manual Page Tracking
Page views are tracked automatically, but you can trigger them manually for SPAs:
// Trigger a pageview manually
Sypnia.page();
// Useful in React Router, Vue Router, etc.
router.afterEach(() => {
Sypnia.page();
});💬 User Feedback
Collect NPS scores or qualitative feedback:
// NPS score (1-10)
Sypnia.feedback(9, 'Love this product!');
// Just a comment
Sypnia.feedback(null, 'The checkout process was confusing');
// Just a score
Sypnia.feedback(7);✨ Best Practices
✅ Do
- • Use consistent naming conventions (snake_case recommended)
- • Keep event names descriptive but concise
- • Include relevant context in properties
- • Track key conversion events (signup, purchase)
❌ Don't
- • Don't track sensitive data (passwords, credit cards)
- • Don't create too many unique event names
- • Don't track every single click or interaction
- • Don't use PII without user consent