Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.saytics.com/llms.txt

Use this file to discover all available pages before exploring further.

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:
npm install @saytics/js
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.
<script
  async
  src="https://cdn.saytics.com/saytics.min.js"
  data-key="YOUR_WRITE_KEY"
></script>
Once installed, initialize the SDK with your write key. Pass an optional configuration object as the second argument to customize behavior.
import Saytics from '@saytics/js';

Saytics.init('YOUR_WRITE_KEY', {
  debug: false,
  batchSize: 10,
});

Configuration options

Pass these options as the second argument to Saytics.init() (browser) or the constructor options object (Node.js).
writeKey
string
required
Your project’s write key from Settings → API Keys. Required to authenticate all events.
debug
boolean
default:"false"
Enable console logging for every event sent and any SDK errors. Useful during development. Disable in production.
apiHost
string
Override the default API endpoint. Use this if you’re proxying Saytics traffic through your own domain.
batchSize
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