@oursprivacy/cdp-sdk
v1.0.1
Published
Ours Privacy CDP SDK for analytics and privacy
Downloads
498
Readme
Ours Privacy CDP Web SDK
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.
Installation
npm install @oursprivacy/cdp-sdk
yarn add @oursprivacy/cdp-sdkUsage
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: '[email protected]',
});
// Reset the users identity
ours.reset();API
ours.init(token, options)
Initialize the SDK. Call this once before tracking.
token(string): Your Ours Privacy project token.options(object): Initialization options:
ours.track(eventName, eventProperties?, userProperties?, defaultPropertyOverrides?)
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.
ours.identify(userProperties)
Set or update properties for the identified user. See supported list here
When to use this package
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 <script> tag version instead, see:
License
MIT
