Developer

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.

Use setConsent() when your site owns consent state:

ts
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

ts
import { init } from "@drip-apex/sdk";
 
init({
  shopId: "demo-shop",
  endpoint: "https://events.drip-apex.com",
  consentMode: {
    enabled: true,
    provider: "onetrust",
    requiredGroup: "C0004"
  }
});
ProviderHow the SDK reads consentDefault group
customReads getter from window when configured, otherwise waits for setConsent().None
onetrustReads getter or window.OnetrustActiveGroups; listens for OneTrust update events.Any non-empty value when requiredGroup is omitted
usercentricsCalls UC_UI.getServicesBaseInfo() and matches service name, ID, template ID, or data processor.Apex
cookiebotReads Cookiebot.consent category booleans. Aliases such as analytics map to statistics.statistics
ccm19Reads CCM.acceptedEmbeddings and matches embedding name or ID.Apex
pandectesCalls 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
cookiescriptCalls 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

FieldTypeDefaultWhen to use
enabledbooleanfalseTurn provider-backed consent detection on.
provider"custom", "onetrust", "usercentrics", "cookiebot", "ccm19", "pandectes", or "cookiescript"Not setSelect the consent integration.
getterstringProvider defaultDot-path on window for custom or OneTrust consent values.
requiredGroupstringProvider defaultRequired 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.