window.homieBot.setConsent().
Report consent on every page view
homie does not remember the consent. Report it on every page view, as soon as the Client API is ready (homiebot:api-ready), and again whenever the visitor changes their choice in your CMP. Until your call arrives, homie treats the visitor as not consenting.
Each example below does two things:
- When the Client API is ready, it reads the current consent from your CMP and passes it to homie.
- It listens for the CMP’s own consent event and passes every change to homie.
Examples for common CMPs
All examples use this helper, which runs your code once the Client API is ready, whether the embed script has already loaded or not:- Usercentrics
Add homie as a service in your Usercentrics settings and use that service’s ID.
usercentrics.js
Accept statistics in your CMP and reload the page. In your browser’s developer tools, the chat’s local storage
contains
homie.visitor after you open the chat. Withdraw consent and open the chat again: the entry is gone.If your CMP already loads the homie script after consent
Some shops load the whole homie script only after the visitor has consented to statistics. In that case, the consent is given whenever the script runs. Report it directly:With this setup, visitors without consent see no chat at all. To offer the chat to every visitor, load the script as
strictly necessary (“Essential” or “Necessary”) and use one of the examples above.
Reference
setConsent(consent)
Passes the visitor’s statistics consent to homie. Returnsvoid.
Any other value is ignored and logged as a warning in the browser console. Calling
setConsent again with a new value replaces the previous one.