Consent modes
Configure Apex SDK consent gating with custom consent, OneTrust, Usercentrics, Cookiebot, CCM19, Pandectes, or CookieScript.
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 |
pandectes | Calls the Pandectes consent purpose methods (for example analyticsProcessingAllowed()), falling back to Shopify's customerPrivacy API. requiredGroup selects the purpose: analytics, marketing, preferences, or sale_of_data. | analytics |
cookiescript | Calls CookieScript.instance.currentState() and reads the selected category. Analytics aliases map to performance, marketing aliases map to targeting, and preference aliases map to functionality. Custom category names remain available. | analytics |
ConsentModeSettings
| Field | Type | Default | When to use |
|---|---|---|---|
enabled | boolean | false | Turn provider-backed consent detection on. |
provider | "custom", "onetrust", "usercentrics", "cookiebot", "ccm19", "pandectes", or "cookiescript" | 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, CCM19, Pandectes (PandectesInitialized and Shopify's visitorConsentCollected), and CookieScript events. On change, the SDK rechecks consent, storage mode, project prerequisites, and tracking permission. The pandectes and cookiescript providers also poll once per second for up to ten minutes. Polling stops after consent grants tracking.