About five minutes, on the free plan, without a credit card.
1
Install the SDK
Privytics runs on the open-source OpenPanel engine, so you use the official @openpanel npm package.
npm install @openpanel/sdk
2
Create the client
apiUrl is an optional option in the SDK and defaults to OpenPanel's own host, so you must set it explicitly to send your events to Privytics. clientSecret is what makes server-side tracking work, so keep it in an environment variable and never ship it to a browser.
// op.ts
import { OpenPanel } from '@openpanel/sdk';
const clientSecret = process.env.PRIVYTICS_CLIENT_SECRET;
if (!clientSecret) {
throw new Error('PRIVYTICS_CLIENT_SECRET is not set');
}
export const op = new OpenPanel({
apiUrl: 'https://api.privytics.com',
clientId: 'YOUR_CLIENT_ID',
clientSecret,
});
3
Track an event
Import the client anywhere in your app and record what happened.
import { op } from './op';
op.track('my_event', { foo: 'bar' });
4
Identify the user
On the server you already know who is making the request. Pass the id you already store for that user as profileId.
import { op } from './op';
op.identify({
profileId: '123', // Required
firstName: 'Joe',
lastName: 'Doe',
email: 'joe@doe.com',
properties: {
tier: 'premium',
},
});
5
Add properties to every event
Useful for stamping release and environment onto everything a service sends, so you can split staging from production.
import { op } from './op';
op.setGlobalProperties({
app_version: '1.0.2',
environment: 'production',
});