About five minutes, on the free plan, without a credit card.
1
Add the snippet to your HTML
Paste both tags into the <head> of every page, or into your template's shared header. Replace YOUR_CLIENT_ID with the client id from your Privytics project. Setting apiUrl is required: if you leave it out, the SDK falls back to OpenPanel's own hosted API instead of yours.
<script>
window.op=window.op||function(){var n=[];return new Proxy(function(){arguments.length&&n.push([].slice.call(arguments))},{get:function(t,r){return"q"===r?n:function(){n.push([r].concat([].slice.call(arguments)))}} ,has:function(t,r){return"q"===r}}) }();
window.op('init', {
apiUrl: 'https://api.privytics.com',
clientId: 'YOUR_CLIENT_ID',
trackScreenViews: true,
trackOutgoingLinks: true,
trackAttributes: true,
});
</script>
<script src="https://privytics.com/op1.js" defer async></script>
2
Track a custom event
Call window.op('track', ...) with an event name and any properties you want to filter or group by later. Calls made before op1.js finishes loading are pushed onto a queue by the stub in step one and replayed once the tracker loads, so you can track from anywhere on the page.
window.op('track', 'signup_completed', {
plan: 'free',
source: 'pricing_page',
});
3
Track clicks without writing JavaScript
Because you enabled trackAttributes, a data-track attribute on a button or link sends that event on click. Every other data-* attribute on the element is passed along as an event property.
<button
data-track="signup_completed"
data-plan="free"
data-source="pricing_page"
>
Create account
</button>
4
Identify a signed-in user
Optional. Pass your own user id as profileId to link sessions into one profile. This is opt-in and you need your own lawful basis for it. Call window.op('clear') on logout to stop attributing events to that profile.
window.op('identify', {
profileId: '123',
firstName: 'Joe',
lastName: 'Doe',
email: 'joe@doe.com',
properties: {
tier: 'premium',
},
});