How to Set Up Consent Logging

Consent Logging (Consent DB) records every consent event from your users, allowing you to query and audit consent records by UUID or user identity. This guide walks you through enabling and using the feature.

Prerequisites

  • Consent DB must be enabled for your account by UniConsent. Contact support@uniconsent.com to enable it.
  • You must be on an Enterprise plan.
  1. Go to your project settings in the UniConsent dashboard
  2. Scroll to the Consent Logging section
  3. Toggle Enable Consent DB to on
  4. Click Save and then Publish your changes

Once published, the CMP will automatically start sending consent events to the Consent DB.

To associate consent records with your users (e.g. after login), add the following code to your page:

<script>
window._unicData = window._unicData || [];
_unicData.push({
    user_ids: {
        auth_uid: 'your_user_id'
    }
});
</script>

This code can be placed anywhere on the page — before or after the CMP script loads. The CMP will pick up the user IDs and include them in consent events.

You can include multiple identity types:

_unicData.push({
    user_ids: {
        auth_uid: 'user_12345',
        email_hash: 'sha256_hash_of_email',
        customer_id: 'CUST-9876'
    }
});
  1. In the sidebar, click Consent Data > Consent Logs
  2. At the top, you'll see key metrics:
    • Consent Records (30d) — Total consent events in the last 30 days
    • Unique IDs — Total unique UUIDs across all time
  3. Use the Search section to query logs:
    • By UUID — Enter a consent UUID to find all records for that device
    • By ID Type + Value — Select an ID type (e.g. auth_uid) and enter the value to find records across devices

Step 4: Add Custom ID Types (Optional)

If you use identity types beyond the system defaults, you can add custom ones:

  1. On the Consent Logs page, click the gear icon in the Search section header
  2. In the Custom ID Types area, enter your custom type name (e.g. loyalty_id)
  3. Click Add

Custom ID types will appear in the search dropdown alongside the system defaults.

Example: Full Integration

<!-- UniConsent CMP tag (async) -->
<script async src='https://cmp.uniconsent.com/v2/YOUR_PROJECT_ID/cmp.js'></script>

<!-- Set user identity (works before CMP loads) -->
<script>
window._unicData = window._unicData || [];

// After user login, push their identity
function onUserLogin(userId, emailHash) {
    _unicData.push({
        user_ids: {
            auth_uid: userId,
            email_hash: emailHash
        }
    });
}
</script>

How It Works

  1. The CMP script loads and reads the project config with enable_consentdb enabled
  2. Any user IDs set via _unicData.push() are picked up
  3. When the user gives or updates consent, the consent event is sent to the Consent DB along with the user IDs
  4. The event is stored in ClickHouse and becomes queryable in the dashboard

Still have questions?

Contact us: support@uniconsent.com