setAnalyticsConsent

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.

Important: Shoplift automatically integrates with Shopify's Customer Privacy API. You only need this method if you have implemented a custom consent solution outside of Shopify's standard privacy tools.

Method Signature

setAnalyticsConsent(consent: boolean): Promise<void>

Parameters

Parameter
Type
Required
Description

consent

boolean

Yes

true to allow analytics tracking, false to deny

Returns

Type
Description

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?