consent.get
Method to receive Commanders Act consent and consent metadata OnSite via JavaScript.
The Commanders Act OnSite API stub has to be installed before using any of the OnSite API functions.
cact('consent.get', function (result) { ... });
The consent.get
method takes one callback JavaScript function as an argument that gets called with the Consent Object that is currently stored on the browser. The callback is called once after Commanders Act CMP JavaScript loaded and validated the stored consent.
The OnSite API works asynchronous. In case you need the consent synchronous (e.g. in the <head>
of a document for AB Testing or personalisation solutions) it is recommended to cache the object in the localStorage
of the browser. In this case it is crucial to implement the consent.onUpdate
method to keep the cached consent in sync.
Examples
Executing code based on the consent setting of a category
In this example the Analytics category was configured with the consent category id 2 in Commanders Act banner.
Executing code based on the consent setting of a category and vendor
In this example the Analytics category was configured with the consent category id 2 and the vendor Google with vendor id 5 in Commanders Act CMP.
Check if consent was already set by the visitor
Checking when the current consent expires
Last updated