Client Setup
Initialize the Node SDK client and user data
Before sending any events, you need to create a client instance with your API key and base URL, and prepare the user data object.
import { Client, UserData } from "audiencelab_nodejs_sdk";
const client = new Client({
apiKey: "<YOUR_API_TOKEN>",
baseUrl: "https://api.yourservice.com",
});
const userData = new UserData()
.setUserId("user_12345")
.setUserIp("123.123.1.1")
.setEventTimestamp("Wed Oct 05 2024 16:48:00 GMT+0200")
.setDeviceInfo({
device_name: "My Device",
height: 2436,
width: 1125,
os: "iOS",
os_version: "14.4",
device_model: "iPhone15,4",
timezone: "America/New_York",
});
⚠️ Important: Detailed device_info is only required during the initial user registration. For later events, you only need to provide user_id and user_ip.
If the event did not happen in real time, include an event_timestamp in ISO 8601 format.
You’re now ready to register the user or fetch the creative token.