Consent DB API (Enterprise only)

Consent DB allows you to log, store, and query consent records in real time. When enabled, every consent event is recorded with the user's UUID, consent string, IP address, and optional identity mappings.

Consent DB is only available to Enterprise accounts. Please contact support@uniconsent.com to enable it.

JavaScript Data Layer API

The Consent DB uses a data layer pattern similar to Google Tag Manager's dataLayer. You can push data to window._unicData at any time — before or after the CMP script loads.

Setup

<script>
window._unicData = window._unicData || [];
</script>

Set User IDs

Link user identities (e.g. after login) to the consent UUID. These IDs will be included in all subsequent consent log events.

window._unicData = window._unicData || [];
_unicData.push({
    user_ids: {
        auth_uid: 'user_12345',
        email_hash: 'sha256_of_email'
    }
});

You can push multiple times — user IDs are merged:

_unicData.push({ user_ids: { auth_uid: 'user_12345' } });
_unicData.push({ user_ids: { loyalty_id: 'LY9876' } });
// Result: { auth_uid: 'user_12345', loyalty_id: 'LY9876' }

Send Identity Event

To immediately send an identity event linking user IDs to the consent UUID without waiting for a consent action:

_unicData.push({
    event: 'send_identity',
    user_ids: {
        auth_uid: 'user_12345'
    }
});

Supported ID Types

The following system default ID types are available:

  • auth_uid — Authenticated user ID
  • email — Email address
  • email_hash — Hashed email address
  • phone — Phone number
  • phone_hash — Hashed phone number
  • customer_id — Customer ID
  • crm_id — CRM ID

You can also define custom ID types in the dashboard under Consent Logs > Search > Settings (gear icon).

You can retrieve the consent UUID from the user's local storage key __unid, or via the JavaScript API:

__unicapi('getConsentId', 2, (consentId) => {
    console.log(consentId);
});

Dashboard

When Consent DB is enabled, a Consent Logs page appears in the sidebar under Consent Data. The dashboard provides:

  • Metrics — Consent records count (last 30 days) and unique ID count
  • Search — Query logs by UUID, or by ID type and value (e.g. find all consent records for a specific auth_uid)
  • Records table — Time, Project, UUID, Consent Type, IP (masked), Page URL, Consent String, User IDs

By UUID

Enter the consent UUID in the UUID search field to find all consent records for a specific device or browser.

By User Identity

Select an ID type (e.g. auth_uid) and enter the ID value to find all consent records across devices linked to that identity.

Still have questions?

Contact us: support@uniconsent.com