Using External IDs with Consent Manager

  • Updated

Setting External IDs

An external user ID can be assigned to a consent record at runtime by leveraging the Osano JavaScript API. The external user ID (userData) is used to tie a user's consent to their unique ID, enabling cross-device consent management.

Note:

  • External IDs can be used exclusively for Cross-Device Consent. Ensure that the Cross-Device Consent feature is enabled in your configuration, or else setting the external ID will have no effect.
  • If Cross-Device Consent is enabled, the userData (external user ID) can be used to store and retrieve consent across devices. The value assigned to the external ID must be unique and consistent for each user.
  • The userData value is stored locally on the user's device alongside their consent and is one-way hashed before being recorded. This value is not sent to Osano's servers and cannot be retrieved by Osano.

 

Example Code for Setting External ID

To set the external ID using the Osano JavaScript API, you can use the following code:

// Assign the external user ID
window.Osano.cm.userData = 'abc123';  // external user ID can be a string or number
console.log(window.Osano.cm.userData); // 'abc123'

 

The window.Osano.cm.userData setter is used to assign a custom external ID to a consent record.

You can also use it in conjunction with an event listener for the osano-cm-initialized event to assign the external user ID:

window.Osano.cm.addEventListener('osano-cm-initialized', function() {
    window.Osano.cm.userData = 'abc123'; // external user ID
});

 

Ensure the external ID is set before the CMP initializes. This can be done by using the preload mechanism. By setting the external ID via this mechanism, the CMP will be aware of it when the page first loads, preventing the banner from showing.

 


Important:
Do not use this capability in a way that could cause non-compliance with privacy laws and regulations.


 

Validating the External ID Assignment

To verify that the external ID (abc123) has been assigned to the consent record:

  1. Open the Network tab in Developer Tools.
  2. Select Record and then Request.
  3. Check that the key extUsrData has the correct value (e.g., abc123).

 

Searching for Consent Records

To search for a consent record using an external ID:

  1. Navigate to https://my.osano.com.
  2. Select Consent Management.
  3. Go to the Consent Records tab and click the search icon.
  4. Use the external ID to search for the specific consent record.