# Node.js

## Installation

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

```bash
$ npm i @luckyorange/server
```

## Usage

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

```javascript
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.

```javascript
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.

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.luckyorange.com/libraries/node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
