Node.js

Use the server library to track events and users as they perform events from your backend systems and APIs.

Installation

Add the official Lucky Orange package to your project via NPM:

$ npm i @luckyorange/server

Usage

After installation, the first step to using Lucky Orange is initializing it with your unique site ID.

const LuckyOrange = require('@luckyorange/server')
const luckyorange = new LuckyOrange({ siteId: 'YOUR-SITE-ID' })

Track events

The track() method accepts three arguments. The first is the name of the event you wish to track. The second is any arbitrary metadata that you want to associate with the event. Finally, you can send a context object. This allows the event to be associated with a particular user that you have identified or a session created by the Lucky Orange browser library.

luckyorange.events.track(
  'Account Created', 
  { acceptedTerms: true }, 
  { userId: 'test-user-123' }
)

Identify users

In order to connect user accounts and their properties in your system with visitor profiles in Lucky Orange, use identify(). You must provide a unique ID that will then become an alias for a visitor created internally by Lucky Orange. If you also use identify() in the browser tracking code, the same user's behavior will be combined into one profile.

luckyorange.visitors.identify('test-user-123', { email: 'test@example.com' })

Last updated