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

ID TypeDescription
auth_uidAuthenticated user ID from your login system
email_hashSHA-256 hash of the email address
customer_idYour internal customer or account ID
crm_idCRM system ID
emailPlain email address
phonePlain phone number
phone_hashSHA-256 hash of the phone number

We recommend using auth_uid or email_hash as the primary identifier. Use hashed IDs instead of plain email or phone when possible — hashed IDs are still searchable in the dashboard while reducing PII exposure.

You can also define custom ID types in the dashboard under Consent Logs > Search > Settings (gear icon). Custom types must be lowercase alphanumeric with underscores, up to 64 characters (e.g. loyalty_id, subscriber_id).

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);
});

Mobile & Native SDK Support

Consent DB is supported across all UniConsent SDKs. Set user identities before launching the CMP — they will be automatically linked to consent records.

Flutter

UniConsent.instance
    .setAppId('your_app_id')
    .setUserIds({'auth_uid': 'user_12345', 'email_hash': 'sha256_of_email'})
    .launchCMP(context);

React Native

<UniConsentProvider
    licenseId="your_app_id"
    userIds={{ auth_uid: 'user_12345', email_hash: 'sha256_of_email' }}
>
    {children}
</UniConsentProvider>

Android

Map<String, String> ids = new HashMap<>();
ids.put("auth_uid", "user_12345");
ids.put("email_hash", "sha256_of_email");

UniConsent.getInstance()
    .setAppId("your_app_id")
    .setUserIds(ids)
    .launchCMP(activity);

iOS (Swift)

UniConsent.shared.setUserIds(["auth_uid": "user_12345", "email_hash": "sha256_of_email"])
UniConsent.shared.launchCMP(rootVC: viewController)

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