Getting Started

The Treliq JavaScript SDK lets your web application identify users, track events, and display in-app content (banners, modals, popovers, tooltips) driven by the workflows you build in the Treliq dashboard.

This guide gets you from zero to a tracked event in five minutes.

Install

npm install @treliq/sdk

The SDK ships ESM, CommonJS, and an IIFE bundle for <script> tags. TypeScript types are bundled.

Initialize

You need two values from the Treliq dashboard:

ValueWhere to find itFormat
Project IDProject settings → GeneralUUID
API keyProject settings → API keystk_live_… or tk_test_…
import { init } from '@treliq/sdk';

const treliq = init({
  apiKey: 'tk_live_xxx',
  projectId: 'your-project-id',
});

Test keys (tk_test_…) auto-enable verbose console logging so you can see every SDK action during development.

Identify the current user

identify() ties the browser session to a stable user ID from your app. Call it once after the user logs in (or on every page load if they’re already authenticated).

await treliq.identify('user_123', {
  email: '[email protected]',
  plan: 'pro',
});

The first argument is your external user ID — any stable string that uniquely identifies the user in your system. The second argument is an optional attributes object that becomes available to your workflows.

Track an event

Once a user is identified, fire events to trigger workflows:

treliq.track('checkout_started', {
  cart_value: 79.99,
  currency: 'USD',
});

Events are batched (10 at a time, every 2 seconds) and flushed automatically. To send immediately:

treliq.track('payment_completed', { amount: 79.99 }, { immediate: true });

Next Steps