Skip to main content

Overview

The Node.js SDK is designed for server-side tracking where you have user identity. It supports:
  • Identified tracking - Use email or userId for user-scoped resolution
  • Customer attribution - Add customerId for account/workspace context, even before a user is known
  • Efficient batching - Events are queued and sent in batches
  • Device tracking - Use fingerprint for desktop/mobile apps (learn more)
Use server-side tracking for events that happen in your backend: subscription changes, feature usage from APIs, background jobs, etc.

Installation

Quick Start

Configuration

Options

string
required
Your organization’s public key.
string
default:"https://app.outlit.ai"
API endpoint for sending events.
number
default:"10000"
How often to automatically flush events (milliseconds).
number
default:"100"
Maximum events per batch before auto-flush.
number
default:"10000"
HTTP request timeout in milliseconds.

API Reference

outlit.track(options)

Track a custom event for a user, a customer, or both.
string
User’s email address. Resolves immediately to a customer profile.
string
Your system-owned user/contact ID.
string
Device identifier for anonymous tracking. See Device Tracking.
string
Your system-owned customer/account/workspace ID.
string
required
Name of the event. Use snake_case.
Record<string, any>
Additional data to attach to the event.
number
Unix timestamp in milliseconds. Defaults to current time.
At least one of email, userId, fingerprint, or customerId is required for track(). customerId-only events are valid immediately and can later link to a resolved customer when identify() uses the same customerId with an email.

outlit.identify(options)

Update user traits without tracking an event. Customer metadata can be included alongside the user identity.
string
User’s email address. Use this or userId to establish user-scoped identity.
string
Your system-owned user/contact ID.
string
Device identifier for linking anonymous events. See Device Tracking.
Record<string, any>
Properties to update on the user profile.
string
Your system-owned customer/account/workspace ID. Send this with email or userId to link the account/workspace to the resolved contact profile.
Record<string, any>
Properties to update on the customer profile.
At least one of email or userId is required for identify(). Customer fields are optional additions.

Activation

Mark activation after a contact completes your product’s activation milestone. This method requires at least one of fingerprint, email, or userId.

outlit.user.activate(options)

Mark a contact as activated. Typically called after a user completes onboarding or a key activation milestone.
The discovered and signed_up stages are automatically inferred from identify calls. Use track() for product activity. Outlit handles engagement and inactivity automatically; see Customer Journey.

Account Billing Methods

Track account billing status. These methods target the account by customerId, not individual contacts. If you’ve connected Stripe, billing is handled automatically.

outlit.customer.trialing(options)

Mark an account as trialing.

outlit.customer.paid(options)

Mark an account as paying.

outlit.customer.churned(options)

Mark an account as churned.
Billing methods target accounts by customerId. Contacts linked to that customer share the same billing status. See Customer Journey for details on how contact stages and account billing work together.

outlit.flush()

Immediately send all queued events. Call this before your process exits.

outlit.shutdown()

Gracefully shutdown: flushes remaining events and stops the timer.

outlit.queueSize

Get the number of events waiting to be sent.

Framework Examples

Express.js

Next.js API Routes

Serverless Functions (AWS Lambda, Vercel)

In serverless environments, always call flush() before returning. The function may be terminated before the background flush runs.

Stripe Webhooks

If you’ve connected Stripe to Outlit, billing status is handled automatically—you don’t need to implement webhook handling yourself. The example below is only needed for custom billing logic.
Track payment and subscription events from Stripe:

Background Jobs (Bull, Agenda)

Common Events to Track

Here are recommended server-side events:

Error Handling

The SDK silently handles errors to not disrupt your application. For debugging:

TypeScript Support

Full TypeScript support is included:

Next Steps

Identity Resolution

Learn how profiles are merged across sources

Customer Journey

Understand contact stages and account billing