Skip to main content
The widget script exposes window.KatlaConsent for programmatic access to consent state.

Prerequisites

KatlaConsent.hasConsent()              // boolean
KatlaConsent.getConsent()              // { type, categories }
KatlaConsent.getAllowedCategories()    // string[]

Checking specific cookies or categories

KatlaConsent.isCategoryAllowed('analytics')   // boolean
KatlaConsent.isCookieAllowed('_ga')           // boolean
KatlaConsent.acceptAll()
KatlaConsent.acceptCategories(['analytics', 'marketing'])
KatlaConsent.rejectAll()
KatlaConsent.optOutOfSale()  // CCPA: opt out of sale/sharing

Listening for changes

KatlaConsent.onConsentChange = (consent) => {
  console.log('Consent updated:', consent)
}
If you use Google Analytics or Google Ads and want to signal consent state via Google Consent Mode v2, use setupGoogleConsentMode() from the SDK:
import { setupGoogleConsentMode } from '@katla.app/sdk';

const cleanup = setupGoogleConsentMode();
This sets default consent to denied for all Google parameters, then automatically updates them when the visitor makes a consent choice. See the Google Consent Mode guide for full details.

Regulation and GPC

KatlaConsent.getRegulation()  // 'gdpr' or 'ccpa'
KatlaConsent.isGPCEnabled()   // true if browser has GPC enabled

Properties

PropertyTypeDescription
siteIdstringYour site’s UUID
categoriesstring[]All available cookie categories

Methods

MethodReturnsDescription
acceptAll()voidAccept all cookie categories
rejectAll()voidReject all non-functional cookies
acceptCategories(categories)voidAccept specific categories
optOutOfSale()voidCCPA: opt out of sale/sharing of personal information
hasConsent()booleanWhether visitor has made a consent choice
getConsent()object | nullCurrent consent state ({ type, categories })
getAllowedCategories()string[]Currently allowed categories
isCategoryAllowed(category)booleanCheck if a specific category is allowed
isCookieAllowed(name)booleanCheck if a specific cookie is allowed
isGPCEnabled()booleanWhether browser GPC signal is active
getRegulation()stringActive regulation ('gdpr' or 'ccpa')