Server SDKs

Register User

Register a user and trigger attribution matching

The RegisterUser API sends device metrics to /v2/fetch-token, triggering probabilistic attribution matching and returning creative token information.

Usage

import {
  Client, UserData, RegisterUser
} from "@geeklab.app/audiencelab_nodejs_sdk";

const client = new Client({
  apiKey: "YOUR_API_KEY",
  baseUrl: "https://analytics.geeklab.app",
});

const userData = new UserData()
  .setUserId("user_12345")
  .setUserIp("203.0.113.42")
  .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",
  });

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

Persist the Token

Pass the response to userData.setUserCreativeTokenInfo(response) before sending events. If your backend recreates UserData per request, persist the returned token, retention dates, cumulative totals, and whitelisted properties in your own store.

After Registration

If you already stored the response elsewhere, restore it on a later request before sending events:

userData.setUserCreativeTokenInfo({
  creativeToken: "abc123-creative-token",
  os_system: "iOS 17.4",
  device_name: "iPhone 14 Pro",
  device_model: "iPhone15,2",
  utc_offset: "+03:00",
  install_date: "2026-06-09T10:00:00+00:00",
  last_login_date: "2026-06-09T10:00:00+00:00",
  wp: {
    "_network": "meta"
  }
});

Then proceed to send events via Fetch Token or directly to Purchase, Ad, or Retention events.