Skip to main content
Add a client object when an event needs customer context. The client data applies to that event payload.

Identify an authenticated customer

Send only fields your privacy policy and consent state allow.
import { track } from "@bilyai/js";

track("user_signed_in", {
  client: {
    userId: "user_123",
    email: "buyer@example.com",
    firstname: "Ada",
    lastname: "Lovelace",
    userGroup: "growth",
  },
  organization_id: "organization_456",
});

Supported client fields

FieldTypePurpose
userIdstringYour stable customer or account ID
emailstringCustomer email when permitted
phonestringCustomer phone when permitted
firstnamestringFirst name
lastnamestringLast name
dateOfBirthstringDate of birth when strictly necessary and permitted
genderstringGender when strictly necessary and permitted
userGroupstringPlan, segment, or account group
addressBilyAddressApproved city, state, postal code, and country fields
BilyAddress accepts city, state, zip, and country.
Do not send customer data by default. Collect the minimum required fields and honor the visitor’s consent and deletion choices.

Browser tracking ID

Use getBilyTrackingId() when you need Bily’s stable browser identifier.
import { getBilyTrackingId } from "@bilyai/js";

const trackingId = getBilyTrackingId();
if (trackingId) {
  console.info("Bily browser ID is available");
}
The return type is string | null. It returns null during server rendering. It is not an authenticated user ID, credential, or authorization value.

Keep identity roles separate

  • Use client.userId for your authenticated account identifier.
  • Use getBilyTrackingId() for the Bily browser identifier.
  • Never treat either value as proof that a request is authorized.
  • Do not place passwords, session tokens, or private keys in any event field.

Tracking ID reference

Identity and attribution

Data safety