Dataships provides the ability to trigger your own code snippets via callbacks on the cookie banner itself.
The following callbacks are available:
Type | Function Name | Description |
---|---|---|
On Load | CookieConsentCallback_OnLoad | async callback triggered when the cookie banner has loaded. |
On Accept | CookieConsentCallback_OnAccept | async callback triggered when the user clicks the accept button and whenever a consented user loads a page. |
On Decline | CookieConsentCallback_OnDecline | async callback triggered when the user clicks the decline button and whenever a user that has declined cookies loads a page. |
Available properties:
Name | Type | Default | Description |
---|---|---|---|
consent.necessary | bool | true | True if current user has accepted necessary cookies. Read Only. |
consent.preferences | bool | false | True if current user has accepted preference cookies. Read Only. |
consent.statistics | bool | false | True if current user has accepted statistics cookies. Read Only. |
consent.marketing | bool | false | True if current user has accepted marketing cookies. Read Only. |
consented | bool | false | True if the user has accepted cookies. Read Only. |
declined | bool | false | True if the user has declined the use of cookies. Read Only. |
hasResponse | bool | false | True if the user has responded to the dialog with either ‘accept’ or ‘decline’. Read Only. |
doNotTrack | bool | false | True if the user has enabled the web browser’s ‘Do not track’ (DNT) setting. Read Only. |
Example:
function CookieConsentCallback_OnAccept() {
// do something cool here
// example usage
if (CookieConsent.consent.statistics) {
// enable google analytics here
}
}