Personyze tracking can be programmatically turned off, on, or queried per visitor — useful for GDPR, CCPA, and other privacy frameworks where users must consent (or actively opt out) before behavioral data is collected.
When to use this
- Cookie consent banners — call
off()by default, thenon()only after the user accepts non-essential / analytics cookies. - Privacy preference centers — let visitors toggle Personyze tracking from a settings page.
- Region-specific compliance — disable tracking for visitors in jurisdictions where consent hasn’t been collected yet.
JavaScript API
Opt out (turn tracking off)
_S_T.system.off()
After this call, no further events are sent to Personyze for the current session. The opt-out state is persisted in the stat_track_off cookie so it survives page navigation. That cookie lasts 730 days (2 years) even when your account sets a shorter cookie lifetime: an opted-out browser no longer runs the tracking that would renew it, so a shorter life would quietly end the refusal. (The public API is unchanged — only where the refusal is stored moved. Opt-outs made before this cookie existed are still honored: the flag’s legacy location inside stat_track_u_id is still read.) See Personyze client-side cookies for the full cookie list, and Consent Mode if you would rather load Personyze and wait for consent than block it entirely.
Opt in (turn tracking on)
_S_T.system.on()
Re-enables event collection. Use this when a visitor grants consent through your cookie banner or preference center.
Check current state
_S_T.system.is_on() // returns true | false
Useful when conditionally rendering UI (“You are currently opted out — click to re-enable”) or in audit logs.
Forget the visitor in this browser
_S_T.delete_cookie()
Deletes the visitor-id and session cookies (stat_track_u_id, _stat_track_s_id) and their copies in localStorage, so the next page view starts as a new visitor. It leaves the opt-out cookie alone. To delete what Personyze holds about the person, use Settings → Data & privacy → Visitor requests.
Common implementation pattern
A typical cookie-consent integration looks like this:
// On page load — opt out by default until consent is given
if (!localStorage.getItem('analytics_consent')) {
_S_T.system.off();
}
// When the user accepts the consent banner
function onConsentGranted() {
localStorage.setItem('analytics_consent', 'granted');
_S_T.system.on();
}
// When the user rejects or revokes consent
function onConsentRevoked() {
localStorage.setItem('analytics_consent', 'revoked');
_S_T.system.off();
}
Generated opt-out code
Settings → Data & privacy → Access & documents → Privacy policy clause and cookie list (also reached from Tracking Code → Privacy & compliance → Privacy policy) gives a copy-ready opt-out snippet for your privacy policy page, under Letting visitors opt out. It renders an on/off switch showing the visitor’s current status; switching it off stops tracking for that visitor and removes any personalization already on the page.
Verifying opt-out is working
- Open your site in a private/incognito window with the dev tools network tab open.
- Filter the requests by
counter.personyze.com. - Trigger the opt-out (call
_S_T.system.off()from the console, or click your privacy banner). - Navigate to a new page on your site. You should see no further requests to
counter.personyze.com. - Run
_S_T.system.is_on()in the console — should returnfalse.
stat-track-lib.js.Related
- Data & privacy settings — How long data is kept, what the tracking code collects, and visitor requests to see or delete their data.
- Personyze client-side cookies — Every cookie and localStorage entry, including
stat_track_off. - Consent mode — Loading Personyze and waiting for consent, rather than blocking it.