Skip to main content
This page covers how to install Saytics in two environments: as a browser JavaScript library for client-side tracking, and as a Node.js library for server-side event collection. Choose the tab that matches your setup — many teams use both.
Install the Saytics JavaScript SDK with npm:
Alternatively, load Saytics from the CDN by adding this script tag to your HTML <head>. The async attribute prevents the script from blocking page rendering.
Once installed, initialize the SDK with your write key. Pass an optional configuration object as the second argument to customize behavior.

Configuration options

Pass these options as the second argument to Saytics.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