Installation
Requirements
- Node.js 18+ (recommended) or any runtime with global
fetch - TypeScript 5+ (optional, for type safety)
Quick Start
Non-Deferred Lead Tracking
Use non-deferred lead tracking when you can send theclickId at the moment you want to record a lead event.
Lead Payload Fields
clickId: string- The unique click identifiereventName: string- Name of the lead event (e.g., “signup_started”, “email_verified”)customerExternalId: string- Your internal customer identifiertimestamp?: string- ISO 8601 timestamp (defaults to current time)customerName?: string- Full name of the customercustomerEmail?: string- Customer’s email addresscustomerAvatar?: string- URL to customer’s avatar/profile picture
Deferred Lead Tracking
Use deferred mode when you can’t reliably send theclickId at the moment of recording a lead event. This enables two-step lead attribution.
Step 1: Store the clickId Association
Step 2: Track Using Only customerExternalId
- In deferred mode’s first call, you associate a
clickIdwith acustomerExternalId - In subsequent calls, you only need the
customerExternalIdthe SDK will use the stored association - This is useful for complex user journeys where the click context may be lost
Sale Tracking
Track sales/conversions with detailed transaction information.Sale Payload Fields
clickId: string- The unique click identifiereventName: string- Name of the sale event (e.g., “purchase_completed”)customerExternalId: string- Your internal customer identifierinvoiceId: string- Invoice or transaction identifieramount: number- Amount in cents (e.g., 4999 = $49.99)currency: string- 3-letter currency code (e.g., “USD”, “EUR”, “GBP”)timestamp?: string- ISO 8601 timestamp (defaults to current time)customerName?: string- Customer’s namecustomerEmail?: string- Customer’s emailcustomerAvatar?: string- URL to customer’s avatar
Configuration
timeout:10000maxRetries:2retryDelayMs:500retryMaxDelayMs:10000retryOnStatuses:[429, 500, 502, 503, 504]retryOnNetworkError:true