Cookie consent banner API

Hey

I’m using the HS Consent Banner on several client sites hosted on 3rd party CMS (WordPress, Webflow etc.).

I’m using a custom JS that listens to the HS consent banner and updates the Google Consent Mode state.

The event for addPrivacyConsentListener seems to be only partially working, and won’t trigger when a user update’s their consent preferences. This is irregardless of that being the user’s initial selection or a later change in preferences.

I’ve also tried using the custom GTM Template by @avoytenko which utilizes the same API but that didn’t help either.

I understand there’s a certain limit as to when the event is triggered, but since this is a dynamic state I also expected the event will be dynamic

Not sure if this is a technical glitch in the event’s behavior or not.

Any thoughts?


@Elad_Levy wrote:

Hey

I’m using the HS Consent Banner on several client sites hosted on 3rd party CMS (WordPress, Webflow etc.).

I’m using a custom JS that listens to the HS consent banner and updates the Google Consent Mode state.

The event for addPrivacyConsentListener seems to be only partially working, and won’t trigger when a user update’s their consent preferences. This is irregardless of that being the user’s initial dental selection or a later change in preferences.

I’ve also tried using the custom GTM Template by @avoytenko which utilizes the same API but that didn’t help either.

I understand there’s a certain limit as to when the event is triggered, but since this is a dynamic state I also expected the event will be dynamic

Consent banner API - HubSpot docs

Not sure if this is a technical glitch in the event’s behavior or not.

Any thoughts?


Based on the HubSpot Consent Banner API documentation (​), the behavior you’re experiencing may not be a glitch but rather an inherent limitation in how the event listener is designed to work.

The addPrivacyConsentListener is primarily triggered when the consent state is initially set, meaning that subsequent updates to a user’s consent preferences might not fire a new event. This design implies that even if a user later updates their preferences, the dynamic state change isn’t propagated through that same listener event.

If you’re using custom JavaScript or a GTM template (like the one by @avoytenko) to update Google Consent Mode, you’ll likely need to implement additional logic to detect and handle these subsequent changes.

One approach might be to poll for changes in the consent state or manually reinitialize the event listener after a consent update.

Thanks

That was my guess, but I’m still failing to understand how can I reinitialize the event listener after a consent update if there’s no event sent :flushed_face:

Polling seems excessive, which leads me to think there might be no option but to switch over to a 3rd party solution (e.g. Cookiebot)