JavaScript SDK (browser)
Everything exported by @optiqstudio/track. The script tag exposes the same calls as optiq("track", …), optiq("identify", …) and optiq("consent", …).
init#
init(options: InitOptions): Tracker | nullStarts tracking on the page, once; later calls return the same tracker. In a server render, or without a valid key, it returns null.
| Name | Type | Description |
|---|---|---|
| keyrequired | string | The source's publishable key (pk_…). |
| auto | boolean | Page views, form starts, leads from marked forms and contacts by themselves. Default true. |
| endpoint | string | Where events go. Default: the Optiq Studio Enterprise collector. |
| consent | Consent | The visitor's choice, if your site already knows it. |
track#
track(name: string, props?: Properties): voidSomething a visitor did. Calls made before init wait for it. Events leave in small batches within half a second, and at once when the page is hidden.
| Name | Type | Description |
|---|---|---|
| value | number | A sale's or deposit's amount. |
| currency | string | Three letters. |
| string | Hashed in the browser; not sent as written. | |
| phone | string | number | Digits only, hashed in the browser. |
| [property] | string | number | boolean | Up to 30 of your own. |
identify#
identify(person: { email?: string; phone?: string | number }): voidWho the visitor is from now on, hashed in the browser. Their later events carry the hash, so a sale your server sends can be joined to this visit.
consent#
consent(state: "granted" | "denied" | "unknown"): voidThe visitor’s choice, remembered on the device. Denied removes the visitor id, the person, the ad click ids and the stored visit; pages are still counted.
page and flush#
page(): void // a page view by hand (auto mode sends them by itself)
flush(): void // send what waits nowsuggest#
suggest(o?: { product?: string; exclude?: string[]; limit?: number }): Promise<{ suggestions: Suggestion[]; recentlyViewed: Suggestion[] }>Products to show this browser’s shopper, and why. Never throws: on any failure both lists are empty. See Personalise.
Helpers#
| Export | Type | Description |
|---|---|---|
| Tracker | class | One tracker on one page, with the same methods. init() makes and shares one. |
| hashPerson | (p) => Promise<string | null> | The SHA-256 the SDK sends for an email or phone. |
| contactChannel | (href) => channel | null | Which contact a link begins: call, email, whatsapp, or null for a share link. |
| COLLECTOR | string | The collector's address. |
Last updated 2026-11-04 UTC. The SDK is open source under the MIT licence. Tell us what is missing.