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.
UNIC_EP_1 … UNIC_EP_4 before loading opt-in category tags.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 | Where IAB TCF applies, true only when the visitor allows storage or any custom vendor: false before a choice and after a reject. Always true where IAB TCF does not apply. Consent category and US opt-out choices do not change it, use UNIC_EP_1 … UNIC_EP_4 and the purpose flags to decide which tags load |
LOC | string | Detected user location |
GEO | string | Region whose rules apply: EU, CA, USCA, a US state such as USTX, US, BR, CN, ZA, VN, or N when none |
EU, US, CA, BR, CN, N | boolean | The flag named by GEO is true, for example USTX. Consent category banners also set each of their region flags |
NPA | 0 or 1 | 1 when only non-personalized ads should be served |
customVendors | object | Custom vendor id to boolean consent |
UNIC_CP_{id} | boolean | Your custom purposes, by purpose ID |
UNIC_P_1 … UNIC_P_10 | boolean | IAB TCF purposes 1 to 10. Outside IAB TCF they follow the policy that applies: advertising purposes turn off after a US opt-out |
UNIC_SF_1, UNIC_SF_2 | boolean | TCF special features (GDPR only) |
UNIC_EP_1 … UNIC_EP_4 | boolean | Consent categories 1 to 4, set in every region. Where IAB TCF applies they follow its purposes, and category 4 (marketing) turns off after a US opt-out |
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
Privacy laws, consent and compliance updates, a few emails a month.