Name | Type | Default | Description |
---|---|---|---|
cookieName |
String |
"cct_choice" |
Name of the cookie used to store consent |
cookieAttributes |
Object |
See defaults | Attributes of the cookie used to store consent |
onConsentLoaded |
Function |
undefined |
Function called when consent status is loaded from user cookies |
onConsentUpdated |
Function |
undefined |
Function called when the user consent is updated |
consentBox |
Object |
See defaults | Options of the consent box |
Type: String
Default: "cct_choice"
Name of the cookie used to store consent
Type: Object
Defaults:
Name | Type | Default |
---|---|---|
path |
String |
"/" |
domain |
String |
undefined |
expires |
Int |
365 |
secure |
Boolean |
false |
sameSite |
String |
"strict" |
Attributes of the cookie used to store consent. See js-cookie documentation for a full description of options.
Type: Function
Default: undefined
Function called when consent status is loaded from user cookies. The consent status is passed as a Boolean
parameter.
{
onConsentLoaded: (hasConsent) => {
if (hasConsent) {
console.log('User said yes to cookies!');
} else {
console.log('User said no to cookies!');
}
}
}
Type: Function
Default: undefined
Function called when the user consent is updated. The consent status is passed as a Boolean
parameter.
{
onConsentUpdated: (hasConsent) => {
if (hasConsent) {
console.log('User said yes to cookies!');
} else {
console.log('User said no to cookies!');
}
}
}
Type: Object
Defaults:
Name | Type | Default | Description |
---|---|---|---|
autoDisplay |
Boolean |
true |
Display the consent box if no user choice has been made |
container |
String |
"container" |
Id of the element the consent box will be appended |
type |
String |
"message" |
Type of the consent box, a unique ok button or two approve/decline buttons |
messages |
Object |
See defaults | Texts displayed inside the consent box |
seeMoreLink |
Object |
{ href: null, target: "_self" } |
Additional link to the website cookie policy |
onOkButtonClick |
Function |
undefined |
Function called when the ok button is clicked (only on message type) |
onApproveButtonClick |
Function |
undefined |
Function called when the approve button is clicked (only on choice type) |
onDeclineButtonClick |
Function |
undefined |
Function called when the decline button is clicked (only on choice type) |
onShow |
Function |
undefined |
Function called when the box appears |
onHide |
Function |
undefined |
Function called when the box disappears |
Type: Boolean
Default: true
Display the consent box if no user choice has been made. As the box DOM is built on first display, setting this option to false
will be equivalent to not using the consent box at all.
Consent Box can still be manually displayed if required.
Type: String
Default: "container"
Id of element in which the consent box will be appended upon build.
<div id="container">
...
<!-- Consent box will be appended at the end of the element -->
</div>
Type: String
Default: "message"
Allowed values: "message"|"choice"
Consent box type which will make the number and label of buttons vary.
Type: Object
Default:
{
message: 'This website uses cookies to provide you the best user experience.',
seeMoreLabel: 'See more...',
okButton: 'Got it',
approveButton: 'Allow Cookies',
declineButton: 'Decline',
}
Texts displayed inside the consent box
Type: Object
Default:
{
href: null,
target: "_self"
}
Additional link to the website cookie policy. If href
is set to null
, no link will be displayed.
Type: Function
Default: undefined
Function called when the ok button is clicked (only on message
type). This function is executed before the consent is actually updated.
Type: Function
Default: undefined
Function called when the approve button is clicked (only on choice
type). This function is executed before the consent is actually updated.
Type: Function
Default: undefined
Function called when the decline button is clicked (only on choice
type). This function is executed before the consent is actually updated.
Type: Function
Default: undefined
Function called when the box appears.
Type: Function
Default: undefined
Function called when the box disappears.