Skip to content

Latest commit

 

History

History
188 lines (136 loc) · 5.5 KB

options.md

File metadata and controls

188 lines (136 loc) · 5.5 KB

Options

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

cookieName

Type: String Default: "cct_choice"

Name of the cookie used to store consent

cookieAttributes

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.

onConsentLoaded

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!');
        }
    }
}

onConsentUpdated

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!');
        }
    }
}

consentBox

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

autoDisplay

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.

container

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

Type: String Default: "message" Allowed values: "message"|"choice"

Consent box type which will make the number and label of buttons vary.

With message type: Message type

With choice type: Choice type

messages

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

seeMoreLink

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.

onOkButtonClick

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.

onApproveButtonClick

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.

onDeclineButtonClick

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.

onShow

Type: Function Default: undefined

Function called when the box appears.

onHide

Type: Function Default: undefined

Function called when the box disappears.