The Splitbee Node.js library provides Splitbee tracking functionality in server-side applications built using Node.js. This is the way to go if you want to send data from your Node server.
Use npm or yarn to install the package @splitbee/node
yarn add @splitbee/node
To get started, initialise the package by replacing the TOKEN
with your project token. You can find it in your project settings.
Make sure to provide a userId
. It is required to link events to the correct user.
const { SplitbeeAnalytics } = require('@splitbee/node');const analytics = new SplitbeeAnalytics('TOKEN');// Track an eventanalytics.track({userId: 'my-custom-user-id',event: 'Payment confirmed',data: {paymentId: '1234567890',},});
Set custom user properties with this function. Data is automatically merged with existing data.
analytics.user.set({userId: 'my-custom-user-id',userData: {username: 'Custom Name',isTrial: true,},});