Javascript API
Our script exposes a number of functions and properties that can be used to programmatically control the consent solution.
All of these handle the consent categories we support:
- undefined = Unknown cookies not yet defined in our tool
- necessary = Strictly necessary cookies
- functional = Functional cookies
- statistical = Statistics cookies
- marketing = Marketing cookies
Below is a reference of the officially supported methods. Any usage beyond this is not officially supported, and functionality cannot be guaranteed. This includes actions such as reading our cookie directly or extracting other information from properties not listed below.
If you have needs that aren’t covered by the current API surface, feel free to contact us and we’ll do our best to find an official way to support it.
This function opens the cookie dialog in the visitor’s browser:
cookieTractor.openConsentSettings()
This function returns true or false depending on whether consent for the specified category is found:
cookieTractor.consent.contains(categoryAlias)
Function to add consent for the specified category. You can call this with a string or an array of strings to add multiple categories:
cookieTractor.consent.add(categoryAlias)
Removes consent for the specified category:
cookieTractor.consent.remove(categoryAlias)
Contains the visitor’s consent key/ID:
cookieTractor.consent.key
A list of strings with categoryAlias for the consents currently given by the visitor:
cookieTractor.consent.current
A list of strings with categoryAlias for all consent categories available on the website. This is a reference list, not the visitor’s choices:
cookieTractor.consent.available
Properties that contain string representations of our consent categories:
cookieTractor.category.{categoryAlias}
// that is:
cookieTractor.category.undefined
cookieTractor.category.necessary
cookieTractor.category.functional
cookieTractor.category.statistical
cookieTractor.category.marketing
Deletes our consent cookie from the visitor’s browser:
cookieTractor.cookie.remove()
Helper function that attempts to delete a cookie by name using the cookieName parameter:
cookieTractor.cookie.remove(cookieName)