Consent modes
Configure Apex SDK consent gating with custom consent, OneTrust, Usercentrics, Cookiebot, or CCM19.
Consent mode lets Apex render variants while delaying persistent storage and tracking until consent is available. The SDK treats consent as required when requireConsent is true, hasConsent is provided, or consentMode.enabled is true.
Custom consent
Use setConsent() when your site owns consent state:
import { init, setConsent } from "@drip-apex/sdk";
init({
shopId: "demo-shop",
endpoint: "https://events.drip-apex.com",
requireConsent: true,
hasConsent: false
});
window.addEventListener("privacy:accepted", () => {
setConsent(true);
});When consent is denied, the SDK clears Apex visitor, goal, signal, config-cache, session, QA, and identity context storage where possible.
Provider modes
import { init } from "@drip-apex/sdk";
init({
shopId: "demo-shop",
endpoint: "https://events.drip-apex.com",
consentMode: {
enabled: true,
provider: "onetrust",
requiredGroup: "C0004"
}
});| Provider | How the SDK reads consent | Default group |
|---|---|---|
custom | Reads getter from window when configured, otherwise waits for setConsent(). | None |
onetrust | Reads getter or window.OnetrustActiveGroups; listens for OneTrust update events. | Any non-empty value when requiredGroup is omitted |
usercentrics | Calls UC_UI.getServicesBaseInfo() and matches service name, ID, template ID, or data processor. | Apex |
cookiebot | Reads Cookiebot.consent category booleans. Aliases such as analytics map to statistics. | statistics |
ccm19 | Reads CCM.acceptedEmbeddings and matches embedding name or ID. | Apex |
ConsentModeSettings
| Field | Type | Default | When to use |
|---|---|---|---|
enabled | boolean | false | Turn provider-backed consent detection on. |
provider | "custom", "onetrust", "usercentrics", "cookiebot", or "ccm19" | Not set | Select the consent integration. |
getter | string | Provider default | Dot-path on window for custom or OneTrust consent values. |
requiredGroup | string | Provider default | Required group, category, service, or embedding identifier. |
Change listeners
When consentMode.enabled is true, the SDK listens for common consent manager browser events including OneTrust, Cookiebot, Usercentrics, and CCM19 events. On change, it rechecks consent, updates storage mode, rechecks project prerequisites, and starts tracking if allowed.