Consent Management
The SDK provides a setConsent() method to update consent state at any time. Consent signals are mapped to Google Consent Mode v2 format and included in every event payload.
setConsent() API
// Grant both analytics and marketing
converlay.setConsent({ analytics: true, marketing: true })
// Deny marketing (e.g., user declines cookie banner)
converlay.setConsent({ analytics: true, marketing: false })
// Update a single signal without affecting the other
converlay.setConsent({ marketing: false })ConsentInput fields
| Field | Type | Default | Description |
|---|---|---|---|
analytics | boolean | true | Allow analytics tracking |
marketing | boolean | true | Allow marketing/ad tracking |
GCM v2 mapping
The SDK maps your consent input to Google Consent Mode v2 signals:
| ConsentInput | GCM v2 signal |
|---|---|
analytics | analytics_storage |
marketing | ad_storage |
marketing | ad_user_data |
marketing | ad_personalization |
Default consent (deny by default)
By default, both analytics and marketing are true. For GDPR-compliant regions, initialize with consent denied:
const converlay = createConverlay({
shopDomain: 'my-store.myshopify.com',
consent: {
analytics: false,
marketing: false,
},
})Events still fire
The SDK sends events regardless of consent state. Consent signals are included in the payload, and Converlay's server uses them to decide which destinations receive each event. This ensures events can be buffered and forwarded once consent is granted.
Shopify Customer Privacy API
If your headless storefront uses Shopify's Customer Privacy API, you can sync consent changes directly:
// Listen for Shopify Customer Privacy API consent changes
if (window.Shopify?.customerPrivacy) {
window.Shopify.customerPrivacy.subscribe(
'visitorConsentCollected',
(event) => {
converlay.setConsent({
analytics: event.analyticsAllowed,
marketing: event.marketingAllowed,
})
}
)
}Third-party consent managers
For consent managers like OneTrust, Cookiebot, or similar:
// OneTrust example
window.OptanonWrapper = () => {
const groups = window.OnetrustActiveGroups || ''
converlay.setConsent({
analytics: groups.includes('C0002'),
marketing: groups.includes('C0004'),
})
}