Skip to main content

JavaScript API

The tracker exposes a small JavaScript API on window.purestats.

Track a pageview

window.purestats?.trackPageview();

Pass a custom path when needed:

window.purestats?.trackPageview('/checkout/success');

Track an event

window.purestats?.track('Signup Completed');

With properties:

window.purestats?.track('Plan Selected', {
plan: 'pro',
billing_cycle: 'annual'
});
window.purestats?.consent(true);

Disable tracking after consent is revoked:

window.purestats?.consent(false);

Load timing

Because pf.js is usually loaded with defer, the API may not exist immediately in inline scripts placed before it. Run custom tracking after the page is ready or after your application initializes.

Data safety

Do not send personal data in event names, paths or properties.