Send Consent on Decision
Connect Hardal consent signals to banner decisions and saved choices, then verify acceptance, denial, and later changes.
Send consent on decision
Connect hrd.consent() to your banner's current choice. Run these handlers after the tracker API is available. The button references and getStoredConsent() helper below represent your own banner implementation; Hardal does not create or store those controls for you.
Call consent in your accept handler
When the visitor accepts, send granted.
acceptButton.addEventListener("click", () => {
hrd.consent("granted");
});
Call consent in your decline handler
When the visitor declines, send denied.
declineButton.addEventListener("click", () => {
hrd.consent("denied");
});
Re-send the stored choice on load
If you save the visitor's choice, send it again when the page loads so the new session starts with the right state.
const saved = getStoredConsent();
if (saved === "granted" || saved === "denied") {
hrd.consent(saved);
}
Verify it
Test acceptance and denial on separate visits, then change an existing choice. Inspect the collection requests for the expected consent state and check subsequent event/session context. A successful request alone does not establish visitor recognition or destination delivery.
Using a consent management platform (CMP)? Call hrd.consent() from the CMP's change callback so Hardal always has the current choice.
Check the measurement context
The signal controls identity processing for collection; it does not choose Acquisition's traffic scope or automatically configure a destination. Read Consent & Privacy for those separate decisions.
For a returning visitor, send the saved current choice after tracker readiness. If your CMP uses different values, map its relevant state explicitly to granted or denied rather than passing an arbitrary object or category name.
Consent Signals
More on what each signal does.