New FS Component Cookie Consent - Update Handler (for Google Maps)

Hi there - I am wondering if there is an updateHandler for the New Component CC. In the old «free» FsCC there was the possibility to do this with:

window.FsCC.consentController.on('updateconsents', (consents) => {});

Is there any similar handler for the new one?

I need such a handler to destroy the Google Map container in the Dom if the Cookie Consent Categories are limited by the user.

I tried to catch things with an onsubmit or onclick handler. But This disturbs the FS Component CC script in some way.

Hey @Tobias! The API has now changed, from the old window.fsCC to window.fsComponents.push([COMPONENT_NAME, callback])

In this case the callback below should be what you are looking for.

<script>
  // you can attach to Finsweet components window object
  window.fsComponents = window.fsComponents || [];
  window.fsComponents.push([
    'consent',
    (instance) => {
      console.log('Consent instance:', instance);
      
      instance?.consentController?.on('updateconsents', (data) => {
        console.log('consents and consent modes updated: ', data);
      });
    },
  ]);
</script>

Let me know if you face any other issues or need any help!

1 Like

Hi @Support-Luis - Big thanks! You hit it again :smiley:

That is the missing piece of code. I just check, if some of the consents is set to false and then trigger a page reload if necessary. This way the FS code stays in lead. It is a bit lazy but works like a charme. Best Tobias

1 Like