Skip to main content
Use getBilyTrackingId() to read the identifier Bily uses for the current browser. The SDK creates one when needed.

Get the identifier

function getBilyTrackingId(): string | null;

Correlate it safely

import { getBilyTrackingId } from "@bilyai/js";

const trackingId = getBilyTrackingId();

if (trackingId) {
  sendSafeCorrelationId(trackingId);
}

Keep it stable in the browser

When browser storage is available, the SDK stores a stable identifier there. If storage is blocked, the SDK keeps an in-memory identifier for the page session. It can also use an existing Bily identifier when one is available. Call this method before or after init().

Handle null on the server

During server rendering, the method returns null. Always handle the nullable return type.
const trackingId: string | null = getBilyTrackingId();

Keep authorization separate

The browser tracking ID is not a password, session token, or authenticated account ID. Never use it to authorize a request. Authorize requests with your own verified session. Use client.userId only for approved account context.

Client data

Separate browser identity, authenticated users, and consent responsibilities.