Skip to content

onMarketingConsentGranted(callback: () => void): void

The onMarketingConsentGranted is used to provide a callback which will be called when the user grants the marketingConsent.

Input parameters

callback

callback is a mandatory parameter of the () => void type which represents a function that will run once marketing consents are granted by the user.

Returned value

A returned value has a type of void as this method does not return anything.

Example

In this example we make a customerPrivacyApi call to fire a callback whenever marketing consents are granted by the user.

useStorefront((storefront) => {
    const customerPrivacyApi = await storefront.getApi('customerPrivacyApi');

    customerPrivacyApi.onMarketingConsentGranted(() => {
        console.log('Marketing consent has been granted!');
    });
});

Customer Privacy API methods reference