Ours Privacy CDP SDK for analytics and privacy
The Ours Privacy CDP Web SDK.
This package lets you send events and user identification data to Ours Privacy from your JavaScript app, without using the browser snippet. Instead of installing a script tag, you install this NPM package.
You can reference all of the Web SDK documentation here.
``bash`
npm install @oursprivacy/cdp-sdk
yarn add @oursprivacy/cdp-sdk
`js
import ours from '@oursprivacy/cdp-sdk';
// Initialize once at app startup
ours.init('YOUR_TOKEN', {
custom_domain: 'https://metrics.example.com',
});
// Track events
ours.track('Purchase Completed', {
price: 29.99,
item: 'T-shirt',
});
// Identify or update user properties later
ours.identify({
email: 'user@example.com',
});
// Reset the users identity
ours.reset();
`
Initialize the SDK. Call this once before tracking.
- token (string): Your Ours Privacy project token.options
- (object): Initialization options:
- See options available here
---
Send an event to Ours.
- eventName (string): Name of the event.eventProperties
- (object): Event-specific properties.userProperties
- (object): Visitor properties to include/update.defaultPropertyOverrides
- (object): Optional per-property overrides.
---
Set or update properties for the identified user. See supported list here
---
Use this NPM package instead of the browser script if:
- You're building a React/Vue/Next.js/Node app and want first-party integration.
- You want TypeScript types and local control over initialization.
- You don't want to load the snippet from the Ours Privacy CDN.
If you want the drop-in