Skip to content

API

setupCookiebot

This function will make sure that the Cookiebot script is injected with the right parameters.

PropertyRequiredDescription
cbidYesThe cookiebot id, which can be retrieved from the account
languageYesThe language in which the banner content should be displayed
autoBlockingModeNo (default true)Auto block scripts that set cookies
onMarketingAcceptNoFunction which will be called when marketing cookies have been accepted
onNecessaryAcceptNoFunction which will be called when necessary cookies have been accepted
onPreferencesAcceptNoFunction which will be called when preference cookies have been accepted
onStatisticsAcceptNoFunction which will be called when statistic cookies have been accepted

loadScript

This function can be used to programmatically inject a script.

PropertyRequiredDescription
elementYesThe DOM reference on which the script will be injected as child
srcYesThe src url of the script
attributesYesAttributes that are placed on the script tag

getCookiebotInstance

The native Cookiebot instance can still be accessed by invoking this function.

javascript
import { getCookiebotInstance } from "@xerius/codey-cookiebot";

console.log(getCookiebotInstance().consented);

Data automation id's

NameDescription
cookiebannerThe cookiebot banner
cookiebot-acceptThe accept all cookies button