文件
瀏覽文件

Let visitors opt out of analytics

Let visitors opt out of analytics with privatus.optOut(), the only flag the tracker stores, and exclude your own visits by browser, IP range or WordPress.

以 Markdown 檢視

For visitors#

js
privatus.optOut()      // stop sending hits from this browser
privatus.optIn()       // undo
privatus.isOptedOut()  // true or false

optOut() stores privatus_optout=1 in localStorage on your domain. It's the only thing the tracker ever writes to the device, and only because the visitor asked for it, which makes it strictly necessary under the ePrivacy Directive (Art. 5(3)). While it's set, the tracker sends nothing: no pageviews, events, engagement, Vitals or clicks. Hits that were waiting for a retry are dropped too.

The flag is per browser and per domain (subdomains have separate storage). If storage is blocked, optOut() does nothing and isOptedOut() returns false.

A ready-made button for your privacy page is in Opt-out snippet. The WordPress plugin provides a [privatus_optout] shortcode.

Browsers that send Global Privacy Control are excluded automatically when the site honours GPC (the default).

For you and your team#

  • Run privatus.optOut() once in the browser console on each of your sites and browsers.
  • Or block your office or VPN IP ranges in traffic rules. The IP is checked in memory and never stored.
  • WordPress: the plugin skips logged-in administrators by default.