Installation
Install the SDK package:Quick Start
Import and use the tracking functions:Core Functions
track()
Tracks a custom event with optional properties.name- Event name (e.g.,"signup","purchase","feature_used")properties- Key-value pairs of event metadata
trackError()
Tracks an error event with context.flush()
Forces all queued events to be sent immediately.clear()
Clears the current session and generates new IDs.Identity Functions
getAnonymousId()
Returns the persistent anonymous user ID.getSessionId()
Returns the current session ID (resets after 30 min inactivity).getTrackingIds()
Returns both anonymous ID and session ID.getTrackingParams()
Returns tracking IDs as URL query string for cross-domain tracking.Utility Functions
isTrackerAvailable()
Checks if the tracker script is loaded.getTracker()
Returns the raw tracker instance.Best Practices
- Use
flush()before navigation - Ensure events are captured before page unload - Call
clear()on logout - Reset identity for multi-user devices - Track errors - Use
trackError()to monitor client-side errors - Cross-domain tracking - Use
getTrackingParams()to preserve identity across domains - Server-side identification - Use
getTrackingIds()to correlate client and server events