Yaap homepageDocs

Collection controls

Choose identified, anonymous or paused collection.

Choose an installation mode

Settings → Installation offers three snippet choices. Changing the selector changes the example code; publish the new snippet on your website to apply it.

ModeBehavior
Full analyticsCollects events with browser and session identifiers.
Anonymous analyticsCollects events without stored visitor/session identifiers.
Wait for consentStarts paused, with identifiers disabled. Your site decides when to resume.

Enabling tracking does not record visitor consent. Connect these controls to your site's consent manager and restore the selected behavior on every page load.

Start paused

<script
  defer
  src="https://analytics.example.com/script.js"
  data-site-id="YOUR_SITE_ID"
  data-identifiers="false"
  data-tracking="paused"
></script>

For npm, use the equivalent initialization options:

const analytics = init({
  siteId: "YOUR_SITE_ID",
  host: "https://analytics.example.com",
  identifiers: false,
  tracking: "paused",
});

Import init from @yaap/client as shown in the npm guide.

Apply a visitor's choice

After the tracker has loaded, use these calls from your consent manager's callback. For npm, you can use the returned tracker instance instead of window.osAnalytics.

Allow identified analytics
window.osAnalytics?.setIdentifiers(true);
window.osAnalytics?.resume();
Allow anonymous analytics
window.osAnalytics?.setIdentifiers(false);
window.osAnalytics?.resume();
Stop collection and remove stored identifiers
window.osAnalytics?.pause();
window.osAnalytics?.setIdentifiers(false);

pause() aborts pending requests and stops collection. resume() records the current page without replaying activity that happened while paused. Disabling identifiers removes stored identifiers while allowing anonymous collection if tracking is running.

If the visitor makes a choice before the script loads, retain that choice in your consent manager and apply it once the tracker is available. Optional chaining alone does not queue a choice.

What anonymous data can show

Anonymous events contribute to event counts and goal completions. Reports that require identified visitors or sessions, including ordered funnels, cannot reconstruct those identities from anonymous events.