Compliant with GDPR, CCPA, COPPA, LGPD, PECR, PDPA, PIPEDA, and more.
Add the UniConsent tag once, with your license key. The tag defines two functions immediately and then loads the full CMP in the background.
<script src="https://cmp.uniconsent.com/v2/cmp.js" data-license="YOUR_LICENSE"></script>
You can find your license key at the Install & Setup section. See Install UniConsent Tags for Web for the full installation guide, including the classic two-part tag for existing installations.
Fires once, when the consent state is final.
Subscribing after it has already fired calls back immediately.
unicReady(function (status) {
if (status.UNIC_P_1) {
loadAnalytics();
}
});
Fires at the same time as unicReady, and again after every consent change
(for example when the user reopens the settings and changes a purpose).
Subscribing late calls back immediately with the current state, then on
every later change. Saves that do not change anything are ignored.
unicUpdate(function (status) {
applyConsent(status);
});
The same data is dispatched on window as unic:ready and unic:update.
Register listeners before the tag so they exist when the events fire.
window.addEventListener('unic:update', function (e) {
applyConsent(e.detail);
});
Place your code anywhere after the tag. Nothing else is required.
<script src="https://cmp.uniconsent.com/v2/cmp.js" data-license="YOUR_LICENSE"></script>
<script>
unicReady(function (status) { /* consent is final */ });
unicUpdate(function (status) { /* every change */ });
</script>
With async, your inline code may run before the tag. Add the two-line
queue guard so calls made early are replayed once the tag loads.
<script async src="https://cmp.uniconsent.com/v2/cmp.js" data-license="YOUR_LICENSE"></script>
<script>
window.unicReady = window.unicReady || function (cb) { (window.unicReady.q = window.unicReady.q || []).push(cb); };
window.unicUpdate = window.unicUpdate || function (cb) { (window.unicUpdate.q = window.unicUpdate.q || []).push(cb); };
unicReady(function (status) { /* consent is final */ });
unicUpdate(function (status) { /* every change */ });
</script>
| Field | Type | Meaning |
|---|---|---|
IS_LOAD | boolean | Consent is final and tags may load |
LOC | string | Detected user location |
GEO | string | Region whose rules apply, N when none |
EU, US, CA, BR, CN, N | boolean | Which region flag applies |
NPA | 0 or 1 | 1 when only non-personalized ads should be served |
customVendors | object | Custom vendor id to boolean consent |
UNIC_P_1 … UNIC_P_10 | boolean | TCF purposes 1 to 10 (GDPR only) |
UNIC_SF_1, UNIC_SF_2 | boolean | TCF special features (GDPR only) |
UNIC_EP_1 … UNIC_EP_4 | boolean | Extended purposes (opt-out regions only) |
unicReady and unicUpdate are reserved names on window. Do not define
functions with these names for other purposes.wait_for_update. If you already set your own Consent Mode
defaults, place them after the tag or they will be overridden.Contact us: support@uniconsent.com