# Analytics opt-out button snippet

> Copy a ready-made opt-out button for your privacy policy page that lets visitors stop being counted by Privatus Analytics in their browser, and how it works.

Visitors can opt out of being counted in their browser. Put this on your
privacy policy page. It works wherever the tracker is installed.

```html
<p id="privatus-optout-status">Checking…</p>
<button type="button" id="privatus-optout-button" hidden>Change</button>

<script>
  (function () {
    var status = document.getElementById('privatus-optout-status');
    var button = document.getElementById('privatus-optout-button');
    function render() {
      if (!window.privatus || !privatus.isOptedOut) {
        status.textContent = 'Analytics isn’t running in this browser, so your visits aren’t counted.';
        return;
      }
      var out = privatus.isOptedOut();
      status.textContent = out
        ? 'Your visits to this site are not counted.'
        : 'Your visits are counted anonymously, without cookies.';
      button.textContent = out ? 'Count my visits again' : 'Don’t count my visits';
      button.hidden = false;
    }
    button.addEventListener('click', function () {
      privatus.isOptedOut() ? privatus.optIn() : privatus.optOut();
      render();
    });
    window.addEventListener('load', render);
  })();
</script>
```

- The choice is stored as `privatus_optout=1` in `localStorage` on your
  domain, only after the visitor clicks. That's the only thing Privatus Analytics
  ever stores in a browser.
- It applies to this browser and this domain. Subdomains (`shop.`,
  `blog.`) have their own storage, so add the button there too, or on each
  domain you use.
- Clearing site data removes the choice.
- If the tracker is blocked (for example by an extension), the snippet
  says so and hides the button: nothing is counted in that browser anyway.

WordPress: use the `[privatus_optout]` shortcode instead. The tracker API
behind this is described in [Opt-out](/docs/tracker/opt-out).
