ConverlayConverlay

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

setConsent()
// 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

FieldTypeDefaultDescription
analyticsbooleantrueAllow analytics tracking
marketingbooleantrueAllow marketing/ad tracking

GCM v2 mapping

The SDK maps your consent input to Google Consent Mode v2 signals:

ConsentInputGCM v2 signal
analyticsanalytics_storage
marketingad_storage
marketingad_user_data
marketingad_personalization

Default consent (deny by default)

By default, both analytics and marketing are true. For GDPR-compliant regions, initialize with consent denied:

Deny by default
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:

Shopify integration
// 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
// OneTrust example
window.OptanonWrapper = () => {
  const groups = window.OnetrustActiveGroups || ''
  converlay.setConsent({
    analytics: groups.includes('C0002'),
    marketing: groups.includes('C0004'),
  })
}