1.1.2 • Published 2 years ago

@luckyorange/server v1.1.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

luckyorange-server

Official library for sending data to Lucky Orange from a Node.js server environment.

Installation

npm i @luckyorange/server

Usage

The following are a few common usage examples to get started sending data to your site in Lucky Orange.

Connecting to your site

The only requirement to get started is passing your site's unique ID to the siteId parameter.

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

Tracking 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 tracking code.

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

Identifying 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.

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

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

If you are also using Lucky Orange in the browser, you can pass an additional visitorId option to identify a visitor already created in the browser. If you skip this step, an entirely new visitor will be created unless the browser has already called identify(). You can get the browser's visitor ID by calling the LO.visitor.getVisitorId() on-page API.

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

luckyorange.visitors.identify('test-user-id', { email: 'test@example.com' }, { visitorId: 'visitor-id-from-browser' })
1.1.1

2 years ago

1.1.2

2 years ago

1.1.0

3 years ago

1.0.0

3 years ago

0.2.0

3 years ago