Setting up cookie consent
How to add the AI Sales Agent to your cookie banner and connect your consent tool, step by step.
Updated:
Until a visitor accepts analytics cookies, the chat widget only sends anonymous, non-identifying statistics. By passing the visitor’s choice to the widget, you unlock conversation analytics for visitors who consented.
Step 1: Add the widget to your cookie banner#
The chat widget uses cookie-like storage for essential functionality (running the chat and keeping the conversation context — these require no consent) and, once consent is granted, for conversation analytics.
Open your cookie banner settings
Sign in to the tool you manage cookie consent with (Cookiebot, CookieYes, OneTrust, your platform’s cookie banner…).
Keep the widget script always loading
Do not put the chat widget script among the scripts your tool blocks until consent — it must always load, otherwise the chat will not appear at all. Without consent the widget sends no analytics; you pass the visitor’s choice to it in step 2.
List the widget in your cookie information
In your cookie banner’s text, list the Yasan chat widget under analytics (statistics) cookies so visitors know what they are consenting to. This is information for visitors — it is not tied to script blocking.
Step 2: Connect your consent tool#
Whenever the visitor makes or changes their cookie choice, pass it to the widget by calling window.Whisper.setConsent(...) with true for accepted categories and false for declined ones:
Enable analytics:
window.Whisper?.setConsent({
analytics: true,
});Enable marketing:
window.Whisper?.setConsent({
marketing: true,
});Disable both:
window.Whisper?.setConsent({
analytics: false,
marketing: false,
});The widget remembers the choice in the visitor’s browser, so the snippet can run on every page load — repeated calls simply store the same value again. If the visitor revokes analytics consent, the widget also deletes its stored visitor identifier and any stored cart snapshot used only for analytics.
Ready-made examples for common tools#
Cookiebot#
window.addEventListener('CookiebotOnConsentReady', () => {
window.Whisper?.setConsent({
analytics: Cookiebot.consent.statistics,
marketing: Cookiebot.consent.marketing,
})
})CookieYes#
document.addEventListener('cookieyes_banner_load', (event) => {
window.Whisper?.setConsent({
analytics: event.detail.categories.analytics === true,
marketing: event.detail.categories.advertisement === true,
})
})
document.addEventListener('cookieyes_consent_update', (event) => {
window.Whisper?.setConsent({
analytics: event.detail.accepted.includes('analytics'),
marketing: event.detail.accepted.includes('advertisement'),
})
})OneTrust#
C0002 (analytics) and C0004 (marketing) are OneTrust’s default category IDs — verify them in your admin under Categorizations → Categories, as they may be configured differently.
function syncWhisperConsent() {
const activeGroups = (window.OnetrustActiveGroups || '').split(',')
window.Whisper?.setConsent({
analytics: activeGroups.includes('C0002'),
marketing: activeGroups.includes('C0004'),
})
}
function OptanonWrapper() {
syncWhisperConsent()
}
window.addEventListener('OneTrustGroupsUpdated', syncWhisperConsent)Where to find these snippets in the app#
The same copy-ready snippets live in the AI Sales Agent settings, in the Cookie consent section.
Not working?#
- The chat widget does not appear at all — your consent tool is probably blocking the widget script. Allow it in the tool’s settings; without consent the widget sends no analytics anyway.
- Conversation analytics stay empty — check that
setConsentis actually called after consent is granted (see the examples above).
More solutions are in Common issues.