Answerly Docs logo
Found 0 Answers

How to listen to PopupHero's cookie consent events

author picture

Fatos Bediu

Founder & Developer

PopupHero provides a way to inform your visitors about the use of cookies on your website and to obtain their consent. To utilize this feature, you can use one of the Cookie Consent templates available with PopupHero.

In this article, we will guide you on how to read, understand, and implement these templates to ensure that your visitors are aware of the cookies being used and have given their consent.

PopupHero emits two events to the main window when a visitor interacts with the cookie consent popup: PopupHero:CookiesAccept and PopupHero:CookiesDecline

These events allow you to track whether your visitors have accepted or declined the use of cookies.

Understanding when the visitor accepts your cookies

window.addEventListener('PopupHero:CookiesAccept ', () => {
    // consent granted
    // activate website functionality that requires user consent

Understanding when the visitor declines your cookies

window.addEventListener('PopupHero:CookiesDecline ', () => {
    // consent declined
    // continue the website without cookies

Did we answer your question?

😃 🤔 ☹️

How can we improve this answer?