Server SDKs

Client Setup

Initialize the Node.js SDK client and user data

Create a Client instance and prepare user registration data.

Client

import { Client } from '@geeklab.app/audiencelab_nodejs_sdk';

const client = new Client({
	apiKey: 'GeekA1B2C3D4-5678-9012-abcd-ef1234567890',
	baseUrl: 'https://analytics.geeklab.app',
});

Prop

Type

UserData

Create a full UserData object when registering a user for attribution. For later in-app events, pass the same user id string directly to AppEvent.

import { UserData } from '@geeklab.app/audiencelab_nodejs_sdk';

const userData = new UserData()
	.setUserId('user_12345')
	.setUserIp('203.0.113.42')
	.setEventTimestamp('2026-06-09T10:00:00+00:00')
	.setDeviceInfo({
		device_name: 'iPhone 14 Pro',
		device_model: 'iPhone15,2',
		os: 'iOS',
		os_version: '17.4',
		height: 852,
		width: 393,
		timezone: 'Europe/Helsinki',
	})
	.setAppVersion('2.5.1')
	.setIfv('6D92078A-8246-4BA4-AE5B-76104861E7DC')
	.setWhitelistedProperties({
		subscription_tier: 'gold',
	});

Prop

Type

Device Info

Prop

Type

IP Forwarding

Always forward the end-user's actual IP address, not your server's IP. This is critical for accurate probabilistic attribution matching.

Registration State

Register a new user once with RegisterUser. Attribution happens only during registration and should be performed preferably in real time.

import { RegisterUser } from '@geeklab.app/audiencelab_nodejs_sdk';

const response = await new RegisterUser(client, userData).send();
userData.setUserCreativeTokenInfo(response);

If an event is sent before the user exists, AppEvent can register and retry automatically when UserData contains the required registration fields.

Whitelisted Properties

Whitelisted properties are durable user properties sent during registration.

userData
	.setWhitelistedProperty('subscription_tier', 'gold')
	.setWhitelistedProperties({ region: 'fi', cohort: 'summer_2026' });

const currentProperties = userData.getWhitelistedProperties();

User properties are limited to 50 keys, 64 characters per key, 256 characters per string value, and 2048 serialized bytes. Keys beginning with _ are reserved.

Session Context

You can attach session context to regular events:

const sessionId = UserData.generateSessionId();
userData.setSessionContext(sessionId);