Install the JavaScript SDK
@optiqstudio/track is the same tracking as the script tag, for sites you build. It ships with types and works with any bundler. A second entry point, @optiqstudio/track/server, sends events from your back end.
Install#
npm install @optiqstudio/trackStart it#
Call init once, as early as you can, with your source’s publishable key:
import { init } from "@optiqstudio/track";
init({ key: "pk_your_publishable_key" });From then on it sends page views (including single-page moves), form starts, leads from forms marked data-optiq="lead", and WhatsApp, call and email presses. During a server render init does nothing, so it is safe to import anywhere.
Send events#
import { track, identify, consent } from "@optiqstudio/track";
track("sign_up", { plan: "gold" });
track("purchase", { value: 1500, currency: "GMD" });
identify({ email: "ama@example.gm" }); // hashed in the browser; never sent as written
consent("denied"); // nothing that tells one person from another is keptCalls made before init wait for it. The names that count towards your campaign are listed in Events, and every function is in the reference.
Videos watched#
It also sends how far each visitor watches each video on the page, as video_progress: when it starts, at 25, 50, 75 and 100%, and when they leave the page, with the seconds actually played (jumps along the timeline do not count) and the video’s length. Any player built on <video> counts when it plays with sound or with its own controls. A muted background loop does not count.
<video src="/films/spring.mp4" controls data-optiq-video="Spring advert"></video> <!-- named -->
<video src="/hero.mp4" autoplay muted loop data-optiq-video="off"></video> <!-- left out -->Turn the automatic events off#
To decide every event yourself, start it with auto: false and send page views by hand:
import { init, page } from "@optiqstudio/track";
init({ key: "pk_your_publishable_key", auto: false });
page(); // on each screenLast updated 2026-11-04 UTC. The SDK is open source under the MIT licence. Tell us what is missing.