Home
Quick start
Identifying users
Tracking events
Tracking groups

Technical Guides

Browser
Node.js
Ruby
Python
HTTP API
License
Sign in

Node.js API

Instant insights from any Node app

Installing

To install the package from NPM into a server-side project, simply run:

1
npm install @june-so/analytics-node --save

Configuring

Now, you must configure the June SDK with a valid API key, which you can get from your June workspace.

1
// Import June SDK:
2
import Analytics from '@june-so/analytics-node';
3
4
// Instantiate the client:
5
const client = new Analytics('MY-KEY');

Identifying users

You can use the identify method to identify your users.

1
// Send an identify call
2
client.identify({
3
userId: '019mr8mf4r',
4
traits: {
5
name: 'Michael Bolton',
6
email: 'mbolton@example.com',
7
plan: 'Enterprise',
8
friends: 42,
9
}
10
});

Identifying companies (optional)

You can use the group method to identify your companies.

1
// Send a group call
2
analytics.group({
3
userId: '019mr8mf4r',
4
groupId: '56',
5
traits: {
6
name: 'Initech',
7
description: 'Accounting Software'
8
}
9
});

Send track events

In order to track user behaviour, you can use the track method.

Note: If you're identifying companies, you should pass the groupId in the track context, as shown in the example below.

1
// Send a track event
2
analytics.track({
3
userId: '019mr8mf4r',
4
event: 'Item Purchased',
5
properties: {
6
revenue: 39.95,
7
shippingMethod: '2-day'
8
},
9
context: {
10
groupId: '1d2dqs3',
11
}
12
});

Our SDK is based on Segment's SDK. You can find more documentation here: https://segment.com/docs/connections/sources/catalog/libraries/server/node