setAnalyticsConsent
Manage Visitor Analytics Consent
The setAnalyticsConsent()
method allows you to manually control visitor analytics consent for Shoplift. This method is only needed if you use a custom consent management platform that doesn't integrate with Shopify's Customer Privacy API.
Method Signature
setAnalyticsConsent(consent: boolean): Promise<void>
Parameters
consent
boolean
Yes
true to allow analytics tracking, false to deny
Returns
Promise<void>
Resolves when consent preference is successfully updated
When to Use This Method
✅ Use When You Have:
Custom consent management platform (OneTrust, Cookiebot, TrustArc, etc.)
Custom-built consent solution
Region-specific consent requirements not handled by Shopify
Need to sync consent across multiple systems
❌ Don't Use When:
Using Shopify's standard Customer Privacy API
No consent management system
Using Shopify's built-in cookie banner
Shopify is already handling consent
Basic Usage
// Set consent to allow analytics
await window.shoplift.setAnalyticsConsent(true);
// Set consent to deny analytics
await window.shoplift.setAnalyticsConsent(false);
Last updated
Was this helpful?