Skip to content

title: Webcomponents - Event Bus - Events - Consents - {consentsName}.withdrawn summary: {consentsName}.withdrawn Event Bus event reference tags: - Webcomponents - Buses - Event Bus - Events - Consents events - {consentsName}.withdrawn


{consentsName}.withdrawn

{consentsName}.withdrawn is an event on the Event Bus that occurs whenever consents are withdrawn. It has four possible names as there are four possible consents. The full names of the event are:

  • analyticsConsent.withdrawn
  • marketingConsent.withdrawn
  • functionalConsent.withdrawn
  • platformAnalyticsConsent.withdrawn

Event body

none

Example

In this example we listen to functionalConsent.withdrawn event and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    storefront.eventBus.on('functionalConsent.withdrawn', () => {
        console.log('Functional consents have been withdrawn');
    });
});

Example

In this example we use a Message Storage API to retrieve an array of past analyticsConsent.withdrawn events.

useStorefront((storefront) => {
    const messageStorageApi = storefront.getApiSync('messageStorageSystemApi');

    const pastWithdrawnEvents = messageStorageApi.getChannelMessages('analyticsConsent.withdrawn');

    if (pastWithdrawnEvents.length > 0) {
        pastWithdrawnEvents.forEach(({ body: eventBody }) => {
            console.log('perform action on every past event');
        });
    }
});

JS API reference