🌐 Global Object
Once the SDK is loaded, you can access it via the global window.Sypnia object:
// Check if SDK is loaded
if (window.Sypnia) {
Sypnia.track('my_event');
}Sypnia.track()
Track a custom event with optional properties.
Sypnia.track(eventName: string, properties?: object): void| Property | Type | Description |
|---|---|---|
eventName* | string | Name of the event (e.g., "signup", "purchase") |
properties | object | Optional key-value pairs of event metadata |
Examples
// Simple 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 tracking
Sypnia.track('feature_used', {
feature: 'export',
format: 'csv'
});Sypnia.identify()
Associate the current visitor with a user ID and traits.
Sypnia.identify(userId: string, traits?: object): void| Property | Type | Description |
|---|---|---|
userId* | string | Unique identifier for the user in your system |
traits | object | Optional user attributes (email, name, plan, etc.) |
Examples
// Basic identification
Sypnia.identify('user_123');
// With user traits
Sypnia.identify('user_123', {
email: 'john@example.com',
name: 'John Doe',
plan: 'pro',
company: 'Acme Inc',
created_at: '2025-01-15'
});Sypnia.page()
Manually trigger a pageview event. Useful for SPAs.
Sypnia.page(): voidExamples
// Trigger pageview after navigation
Sypnia.page();
// React Router integration
useEffect(() => {
Sypnia.page();
}, [location.pathname]);
// Vue Router integration
router.afterEach(() => {
Sypnia.page();
});Sypnia.feedback()
Collect user feedback or NPS scores.
Sypnia.feedback(score: number | null, message?: string): void| Property | Type | Description |
|---|---|---|
score | number | null | NPS score (1-10) or null for comment-only feedback |
message | string | Optional feedback message or comment |
Examples
// NPS score with comment
Sypnia.feedback(9, 'Love this product!');
// Just a score
Sypnia.feedback(7);
// Just a comment
Sypnia.feedback(null, 'The checkout process was confusing');📋 Automatic Properties
These properties are automatically added to every event:
| Property | Type | Description |
|---|---|---|
session_id | string | Unique session identifier |
visitor_id | string | Persistent visitor identifier |
timestamp | string | ISO 8601 timestamp |
url | string | Current page URL |
path | string | URL path |
referrer | string | Referrer URL |
title | string | Page title |
browser | string | Browser name (Chrome, Firefox, etc.) |
os | string | Operating system |
device_type | string | "desktop" or "mobile" |
screen_width | number | Screen width in pixels |
screen_height | number | Screen height in pixels |