Web SDKv8.21.10MIT License
JavaScript SDK
acai-js is the browser SDK for vanilla JavaScript projects. It persists events to localStorage, manages sessions, and auto-captures UTM parameters, referrer, and click IDs.
Using React, Vue, or Svelte? Consider the TypeScript Browser SDK — it has a plugin system, autocapture, and first-class TypeScript support.
Installation
Or load via async snippet — paste in your <head>:
Initialise
Multiple named instances:
Track events
Identify users
To log out a user:
Groups
Revenue
Config reference
| Option | Type | Default | Description |
|---|---|---|---|
apiEndpoint | string | api.acai.yourdomain.com | Collector host (no https://). |
forceHttps | boolean | true | Always use HTTPS for requests. |
batchEvents | boolean | false | Buffer events and send in batches. |
eventUploadThreshold | number | 30 | Batch size that triggers a flush. |
eventUploadPeriodMillis | number | 30000 | Flush interval in ms. |
saveEvents | boolean | true | Persist unsent events to localStorage. |
savedMaxCount | number | 1000 | Max events saved to storage. |
sessionTimeout | number | 1800000 | Session inactivity timeout (30 min). |
includeUtm | boolean | false | Auto-capture UTM parameters. |
includeReferrer | boolean | false | Auto-capture page referrer. |
includeFbclid | boolean | false | Auto-capture Facebook click ID. |
includeGclid | boolean | false | Auto-capture Google click ID. |
logLevel | string | WARN | DISABLE · ERROR · WARN · INFO |
optOut | boolean | false | Disable all tracking. |
disableCookies | boolean | false | Use localStorage instead of cookies. |
cookieExpiration | number | 365 | Cookie expiry in days. |
sameSiteCookie | string | Lax | Lax · Strict · None |
transport | string | http | http or beacon (sendBeacon API). |
deferInitialization | boolean | false | Delay tracking until enableTracking() is called. |
onError | function | — | Called when an event fails to send. |
