Skip to content

onPlatformConsentGranted(callback: () => void): void

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

Input parameters

callback

callback is a mandatory parameter of the () => void type which represents a function that will run once platform analytics 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 platform analytics consents are granted by the user.

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

    customerPrivacyApi.onPlatformConsentGranted(() => {
        console.log('Platform analytics consent has been granted!');
    });
});

Customer Privacy API methods reference