- Browser
- Node.js
Install the Saytics JavaScript SDK with npm:Alternatively, load Saytics from the CDN by adding this script tag to your HTML Once installed, initialize the SDK with your write key. Pass an optional configuration object as the second argument to customize behavior.
<head>. The async attribute prevents the script from blocking page rendering.Configuration options
Pass these options as the second argument toSaytics.init() (browser) or the constructor options object (Node.js).
string
required
Your project’s write key from Settings → API Keys. Required to authenticate all events.
boolean
default:"false"
Enable console logging for every event sent and any SDK errors. Useful during development. Disable in production.
string
Override the default API endpoint. Use this if you’re proxying Saytics traffic through your own domain.
number
default:"10"
Number of events to accumulate before flushing to the API in a single request. Reducing this value sends events more frequently; increasing it reduces network requests.
Use your write key (not secret key) for client-side code. The write key is safe to expose in browser environments.
Next steps
- Quick start guide — send your first event end-to-end
- JavaScript SDK reference — all available methods and advanced options