JavaScript SDK (server)
The server half of the SDK, @optiqstudio/track/server, for Node 20 or later, Deno, Bun and edge runtimes.
new Optiq#
new Optiq(options: { secretKey: string; baseUrl?: string; retries?: number })| Name | Type | Description |
|---|---|---|
| secretKeyrequired | string | The source's secret key (sk_…). Throws if it is not one. |
| baseUrl | string | Default https://enterprise.optiq.studio |
| retries | number | Tries for a busy answer (429, 5xx or none). Default 3, with growing pauses. |
optiq.track#
optiq.track(events: ServerEvent | ServerEvent[]): Promise<{ accepted: number; duplicates: number; rejected: { index: number; reason: string }[] }>Sends one event or many; any number go 500 at a time. Each email and phone is hashed before it leaves, and an event_id is made for any event without one. A ServerEvent takes the fields on every event, plus:
| Name | Type | Description |
|---|---|---|
| last_ref | string | The tracked link that brought them, when you know it better than the browser did. |
| last_ref_at | string | Date | When that link was pressed. |
| click_ids | object | gclid, fbclid, ttclid, wbraid or gbraid. |
optiq.suggest and optiq.profile#
optiq.suggest(o: { email?; phone?; person_hash?; visitor_id?; product?; exclude?: string[]; limit? }): Promise<{ suggestions; recentlyViewed }>
optiq.profile(who: { email?; phone?; person_hash?; visitor_id? }): Promise<Profile>Suggestions for one customer across every device they used, and everything your company knows about them. The email or phone is hashed by Enterprise on arrival and not kept. See Personalise.
optiq.forget#
optiq.forget(who: { email?: string; phone?: string | number; person_hash?: string; visitor_id?: string }): Promise<{ deleted: number }>Removes every event and visit of that person in your company, and of every browser they were seen on. Only the hash is sent.
Errors#
A refusal throws an OptiqError with the answer’s status and a sentence saying why. A bad key is 401, too many events in one call is 413, and an event that cannot be kept is listed in rejected instead. Busy answers are tried again first.
import { Optiq, OptiqError } from "@optiqstudio/track/server";
try {
await optiq.track(events);
} catch (e) {
if (e instanceof OptiqError && e.status === 401) alertTheTeam("The Optiq secret key was revoked.");
else throw e;
}Last updated 2026-11-04 UTC. The SDK is open source under the MIT licence. Tell us what is missing.