Send events from your server
Sales, deposits and anything a browser cannot be trusted with come from your server, with your source's secret key.
Why from the server#
A browser can be closed before an event leaves, blocked, or edited. Your server knows for certain when money moved. Send those events from there:
- a purchase;
- a first deposit;
- a subscription;
- an account opened after checks.
Node.js and edge runtimes#
npm install @optiqstudio/trackimport { Optiq } from "@optiqstudio/track/server";
const optiq = new Optiq({ secretKey: process.env.OPTIQ_SECRET_KEY! });
// When a deposit clears:
await optiq.track({
name: "first_deposit",
event_id: deposit.id, // your own id: a repeat counts once
email: customer.email, // hashed here before it is sent
value: deposit.amount,
currency: "GMD",
occurred_at: deposit.clearedAt,
});It runs on Node 20 or later, Deno, Bun, Cloudflare Workers and other edge runtimes. Emails and phones are hashed with SHA-256 on your server, so Enterprise never receives them as written.
Any other language#
The SDK is a thin layer over one HTTPS call. From PHP, Python, Java or anything else, send the hash yourself: SHA-256 of the trimmed, lower-case email, or of the phone’s digits only.
curl -X POST https://enterprise.optiq.studio/api/v1/events \
-H "Authorization: Bearer $OPTIQ_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"events":[{"event_id":"dep_1042","name":"first_deposit","person_hash":"<sha256>","value":500,"currency":"GMD"}]}'How a deposit finds its video#
Your server seldom knows which link brought the customer, but their browser did. An event that names no link is joined to the same person’s latest visit within the seven days before it. Enterprise looks first for their hashed email or phone, then for the visitor_id.
- On your site, call
identify({ email })or mark the sign-up form withdata-optiq="lead", so the browser’s visit carries the same hash. - Or pass the visitor id to your server (it is in
localStorageasoptiq_vid) and send it asvisitor_id.
Retries and repeats#
Each event_id counts once per source. If a call fails or times out, send it again with the same id: nothing is counted twice. The SDK retries busy answers (429 and 5xx) by itself, and splits more than 500 events into several calls. See Limits and errors.
Last updated 2026-11-04 UTC. The SDK is open source under the MIT licence. Tell us what is missing.