Consent mode

Where the law requires opt-in consent for analytics (EU/UK ePrivacy and GDPR, Türkiye's KVKK), recording must not start until the visitor says yes. logcohort ships this as a pure API — deliberately not another banner. You already run a consent tool (or your own banner); logcohort plugs into whatever it is, and if your audience doesn't require consent, nothing changes for you.

Record nothing until consent

Add requireConsent: true to your init call. Until a grant arrives, the SDK records nothing and stores nothing — no events, no cookie, no visitor id, not a single network request:

logcohort('init', 'lc_YOUR_PROJECT_KEY', { requireConsent: true });

The consent call

// wherever your consent UI resolves:
logcohort('consent', true);   // start recording
logcohort('consent', false);  // stop, and erase the visitor id

Call it any time — before or after init, on page load or mid-session. The command queue makes it race-free. Three behaviors worth knowing:

logcohort deliberately does not persist the decision: your consent tool is the system of record and re-signals on every page load, which is how every CMP already works.

OneTrust

// OneTrust: react to the consent event; C0002 = Performance/Analytics
window.addEventListener('OneTrustGroupsUpdated', function () {
  var groups = (window.OnetrustActiveGroups || '');
  logcohort('consent', groups.indexOf(',C0002,') !== -1);
});

Cookiebot

// Cookiebot: statistics consent gates recording
window.addEventListener('CookiebotOnConsentReady', function () {
  logcohort('consent', !!(window.Cookiebot &&
    window.Cookiebot.consent && window.Cookiebot.consent.statistics));
});

Google Tag Manager (Consent Mode)

// Google Tag Manager, Consent Mode: fire a tag when
// analytics_storage is granted, with this HTML:
<script>
  logcohort('consent', true);
</script>
// and a matching tag on the denied state calling
// logcohort('consent', false).

No pre-consent buffering, by design. Some tools record into memory before consent and transmit after acceptance. logcohort doesn't: "we recorded before you said yes, we just hadn't sent it" is not a position we'll put you in.