CookieChimp object (also available as window.CookieChimp). Everything on this page is read from — or called on — that object. Use it to:
- Read data — what the visitor consented to, and which banner was served to them (country, region, consent mode).
- Listen for events — react the moment consent is given, changed, or the modal is shown or hidden.
- Control the banner — show, hide, accept, reject, or reset consent programmatically.
Reading visitor & banner data
CookieChimp exposes properties on theCookieChimp object that tell you about the visitor’s location and the banner that was served to them. They’re useful when you want to customise behaviour or tags based on country, region, or consent mode — without duplicating banners.
CookieChimp.visitorCountry
The ISO 3166-1 alpha-2 country code of the visitor (e.g. "US", "GB", "CN", "DE").
CookieChimp.visitorRegion
The region/subdivision code of the visitor (e.g. "NY" for New York, "CA" for California). Useful when compliance rules differ by region within a country — for example, US state privacy laws.
CookieChimp.visitorNeedsConsent
true if a consent banner was shown to the visitor (either an opt-in or opt-out banner), false if the visitor's location does not require one.
CookieChimp.getConfig()['mode']
Returns the consent mode that was applied to the visitor based on your geolocation rules:
"opt-in"— the visitor was shown an opt-in banner (e.g. EU/EEA visitors under GDPR)."opt-out"— the visitor was shown an opt-out banner (e.g. US visitors under CCPA-style regulations).
getConfig()
Returns the resolved configuration for the banner that was served to the current visitor. The most commonly read field is mode:
Reading the visitor’s consent
getUserPreferences
Returns the visitor’s accepted/rejected categories and services. This is the primary way to read what the user consented to.
Type: function(): object
acceptedCategory
Returns true if the specified category was accepted by the user, otherwise false.
acceptedService
Returns true if the specified service was accepted by the user, otherwise false.
validConsent
Returns true if consent is valid.
Consent is NOT valid when at least one of following situations occurs:
- consent is missing (e.g. user has not yet made a choice)
- CookieChimp’s cookie does not exist/has expired
- CookieChimp’s cookie is structurally not valid (e.g. empty)
Listening for events
Every event is a standard DOM event dispatched onwindow. Subscribe with window.addEventListener and read the data from event.detail.
CookieChimp dispatches three families of events:
Consent events
These fire whenever the visitor’s consent state changes. For example, when the visitor gives consent for the first time, reloads a page on which consent is already stored, or changes their preferences from the privacy trigger.cc:onFirstConsent
Triggered the first time the user expresses their choice of consent (accept/reject).
cc:onConsented
Triggered the very first time the user expresses their choice of consent — just like onFirstConsent — but also on every subsequent page load.
cc:onUpdate
Triggered when the user modifies their preferences, and only if consent has already been provided.
Modal events
These cover the lifecycle of the consent banner and preferences modal — from being attached to the DOM to being shown and hidden.cc:beforeModalShow
Dispatched right before the consent modal is shown. This event is cancelable — call event.preventDefault() to prevent the banner from appearing. You can then show it later programmatically via CookieChimp.show(true).
cc:onModalShow
The consent modal is visible.
cc:onModalHide
The consent modal is hidden.
cc:onModalReady
The consent modal is created and appended to the DOM. This is the safest place to read visitor & banner data, because those properties are guaranteed to be populated by the time it fires.
Consent string events
CookieChimp also publishes the visitor’s choices as a flat, comma-separated string onwindow.cookieChimpConsentString. The Adobe Launch integration is built on this property and the matching event below — it pairs well with any setup that prefers a single value over the structured getUserPreferences() object.
Google Tag Manager uses its own consent signal — a
cookiechimp_consent_update
push on dataLayer, not this DOM event. See the Google Tag
Manager guide for the GTM-specific setup.window.cookieChimpConsentString
A comma-separated list of every category and service the visitor has accepted, for example:
cc:consentStringUpdated listener (below) always reflects the latest state.
cc:consentStringUpdated
Triggered once consent has been granted and again every time the visitor changes their preferences, after window.cookieChimpConsentString has been rebuilt.
Controlling the banner
show
Shows the consent banner. If consent was previously expressed, the consent modal will not be generated; you’ll have to pass the argument true to generate it on the fly.
hide
Hides the consent banner.
showPreferences
Shows the preferences modal.
hidePreferences
Hides the preferences modal.
acceptCategory
Programmatically accept or reject a cookie category.
acceptService
Accepts or rejects services.
reset
Resets CookieConsent by dropping all internal pointers and config. You can pass the argument true to delete CookieChimp’s cookie which holds the user’s consent & preferences. The user will be prompted again to express their consent.
Next steps
- Advanced Banner Overrides — full end-to-end recipes built on the properties and events above.
- Custom Update Consent Button — wire
showPreferencesto your own button. - Custom CSS — the full list of CSS variables you can override.