JavaScript API
cookieman. exposes these methods:
cookieman.showOnce()
- cookieman.showOnce()
- 
    |Data type: void|Shows the confirmation modal when consent has not been saved yet. It is automatically called on each page from cookieman-(with an aditional condition, see When is the popup shown to users?)init. js 
cookieman.show()
- cookieman.show()
- 
    |Data type: void|Shows the confirmation modal. You can also use the attribute data-on any element to show the modal when clicked.cookieman- show <button data-cookieman-show> Adjust your cookie preferences </button>Copied!
cookieman.hide()
- cookieman.hide()
- 
    |Data type: void|Hides the confirmation modal. 
cookieman.consent(groupKey)
- cookieman.consent(groupKey)
- 
    |Adds the given group (e.g. 'marketing') to the consented groups, updates the CookieConsent cookie and injects all items given each corresponding trackingObject'sinjectsection.This is meant as a programmatic way to implement banners before showing content from external sources such as YouTube videos, Google Maps, facebook posts, ... – clicking the "yes, show the content"-button would call this function and a <script>in trackingObject'sinjectsection would take care of actually loading the content.
cookieman.consenteds()
- cookieman.consenteds()
- 
    |Data type: array|Example: ["mandatory", "ads"]|Returns all groups keys the user has consented to. 
cookieman.hasConsented(groupKey)
- cookieman.hasConsented(groupKey)
- 
    |Data type: boolean|Returns trueif the user has consented to the given group (e.g. 'marketing'), else false.
cookieman.hasConsentedTrackingObject(trackingObjectKey)
- cookieman.hasConsentedTrackingObject(trackingObjectKey)
- 
    |Data type: boolean|Returns trueif the user has consented to all groups (A group is any name of a checkbox in the popup, e.g. 'marketing') that contain the given trackingObject, else false.trackingis the trackingObjects.‹tracking object key› from TypoScript, e.g. 'Matomo'.Object Key 
cookieman.onScriptLoaded(String trackingObjectKey, int scriptId, function callback)
- cookieman.onScriptLoaded(String trackingObjectKey, int scriptId, function callback)
- 
    |Data type: void|Do things after an external script has been loaded. This is useful if you are interacting with external scripts that are loaded by Cookieman. - trackingis the trackingObjects.‹tracking object key› from TypoScript, e.g. 'Matomo'.- Object - Key 
- scriptis the number of the <script> inside your trackingObjects.‹tracking object key›.inject (starting from 0 with the first).- Id 
- callbackis a function reference. It receives trackingObjectKey and scriptId (see example below). The callback is called immediately if the referred to <script> has already finished loading.
 Example: cookieman.onScriptLoaded( 'Matomo', 0, // first script in 'inject' function (trackingObjectKey, scriptId) { _paq.push(['trackConversion']) } )Copied!
Tip
Cookieman also includes the (1kB) cookie library JavaScript Cookie that also exposes its API and makes it easier to work with cookies.