LearnConsent Signals

Consent Signals

Tell Hardal when a visitor grants tracking, and see what each signal adds on top of privacy-first analytics.

On a first visit without a consent signal or an existing identity cache, Hardal measures the session anonymously and does not write an identity cookie. You can still see traffic, channels, sessions, and session-level attribution. After consent is granted, Hardal can recognize later activity for the same tenant and source.

After the tracker loads, call this handler from your banner whenever the visitor makes or changes their analytics choice. Pass true for acceptance and false for refusal.

function onAnalyticsChoice(allowed) {
  if (typeof allowed === "boolean") {
    return hrd.consent(allowed ? "granted" : "denied");
  }
}

Check hrd.consentStatus().data.consent in the browser console. On a fresh visit it starts as unknown. After the visitor makes a choice, it should match the latest decision (granted or denied).

What each signal changes

SignalWhat happens
grantedHardal can process identity fields and writes a secure first-party identity cookie for the same tenant and source.
deniedHardal keeps measuring anonymously, removes identity fields, and clears an existing identity cookie.

Until a signal arrives, Hardal measures anonymously unless a valid identity cookie from an earlier granted request exists for the same tenant and source.

Send the signal as soon as the visitor decides so the rest of the session uses their current choice.

On the banner decision

Call hrd.consent("granted") or hrd.consent("denied") in your banner's accept and decline handlers.

On a later change

If the visitor changes their choice in your preferences, send the new signal. The latest signal wins.

On return visits

If you know the saved choice before the tracker loads, set its initial consent so the first automatic event uses that choice. If the choice becomes available later, call hrd.consent() when it does.

For server-side events, pass the current choice in x-hrd-consent. See API & Server-side Setup for the request headers.

  • Without identity consent: Hardal can collect anonymous analytics without keeping userId or visitorId. Your consent and disclosure requirements still depend on your implementation and applicable law.
  • With granted consent: Hardal can preserve identity fields and recognize activity across requests for the same tenant and source.

For the full picture, see Consent & Privacy in the User Guide.

Verify your implementation

Test a first visit, acceptance, denial, and a later change of choice. Send the current choice after the tracker is available, inspect the collection request, and check the related event/session context. A consent method call by itself does not prove that a visitor ID was supplied or that a destination received an event.

Keep identity consent and destination delivery requirements separate. Read Consent & Privacy.

Send Consent on Decision

A short guide to wiring consent into your banner.