CDPGuidesSupport
SDKsIngest

Node.js SDK (ingest)

Quickly integrate the Ours Privacy Node.js SDK using npm. Send test requests from the Track Events API reference.

Use this page to install the Ours Privacy Node.js SDK and send events from your server. Every request takes your Ingest API source's API key as token. Copy it from the API Keys card on the source's Settings tab.

Installation

Install the SDK via npm:

npm install @oursprivacy/server-sdk

For more details, visit the NPM Repo | Github Repo.

Usage

Create a client and track an event:

import OursPrivacy from '@oursprivacy/server-sdk';

const client = new OursPrivacy();

// Track an event
await client.track.event({
  token: 'your-source-token',
  event: 'Purchase',
  userId: 'user123',
});

// Identify a user
await client.visitor.upsert({
  token: 'your-source-token',
  userId: 'user123',
  userProperties: {
    email: 'user@example.com',
    first_name: 'John',
    last_name: 'Doe',
  },
});

Next Steps

How is this guide?

On this page