Installation
Install the SDK using your preferred package manager.Initialization
Initialize the SDK once at the entry point of your application, before any tracking calls are made.YOUR_WRITE_KEY with the write key from your Saytics workspace settings. When autoPageview is true, the SDK automatically sends a page view event on every navigation change, so you don’t need to call Saytics.page() manually for standard page loads.
Core methods
track(event, properties)
Usetrack to record any action a user takes in your app. The first argument is the event name; the second is an object of properties that describe the action.
page(name, properties)
Usepage to record a page view when autoPageview is disabled, or when you need to attach extra context to a view.
identify(userId, traits)
Useidentify to associate the current user with a known user ID and optional profile traits. Call this after login or sign-up.
reset()
Usereset to clear the anonymous session ID, typically when a user logs out.
Framework examples
The SDK integrates with any JavaScript framework. The examples below show where to place your tracking calls in the most common setups.- React
- Vue
- Vanilla JS
In React, place
Saytics.track inside a useEffect hook to fire tracking calls after a component mounts.Call
Saytics.reset() when a user logs out to prevent associating future events with the previous user’s profile.