Deprecated
GDPR
__cmp(command, parameter, callback)
Didomi is fully compliant with the CMP API from the IAB Transparency and Consent framework version 1.
We expose a __cmp
function and listen to postMessage
events as per the specification.
Example (getting the IAB consent string):
Read more in the IAB documentation
The __cmp function belongs to the IAB Transparency and Consent framework version 1, which is officially deprecated since 8/15/2020.
getObservableOnUserConsentStatusForVendor(vendorId)
Deprecated, use addVendorStatusListener instead.
Get an observable on the consent status for a given vendor. By subscribing to the observable, you can define a function that gets called whenever the consent status of a given vendor changes.
We use the list of purposes declared for the vendor to make sure that it has consent for all of them. The required purposes are automatically setup for IAB or Didomi vendors and you must specify the required purposes for your custom vendors when configuring the tag.
It also allows you to filter for specific types of updates so that you can react to certain events only. It is an alternative to listening to the consent.changed
event that helps in dealing with vendor-specific operations.
This is commonly used to observe the consent status for a vendor to decide when to load/enable the vendor on a page.
Parameters
Name | Type | Description |
---|---|---|
vendor |
| The ID of vendor that to check the user consent for. If you are checking an IAB vendor, use an integer instead of a string. Custom vendor IDs must be prefixed with |
Returns
Observable
on the consent status of the vendor.
The observable is not a real RxJS observable and only supports the following operators: distinctUntilChanged, filter and first. These operators behave the same as in RxJS.
Examples:
Example 1 - Get all updates to the consent status for a vendor
With this structure, your function gets called when the user gets on the page and every time the consent status of the user changes.
Example 2 - Get updates when the consent status is true or false
With this structure, your function only gets called after the user has given consent information. It could be on page load if the user had already given consent on a previous page or every time the user interacts with the Didomi widgets to change their consent information. When the consent status is unknown, your function does not get called.
Example 3 - Get the first update to the consent status of the vendor
With this structure, your function gets called exactly once with the first available consent status. If the user has not given consent yet, your function will get called with undefined
. If the user has already given consent, your function will get called with the consent status from the user.
Example 4 - Get the first true or false update to the consent status of the vendor
With this structure, your function gets called exactly once when the consent status becomes available. If the user has not given consent yet, your function will only be called after the user has given consent. If the user has already given consent, your function will immediately get called with the consent status from the user. Your function will never get called with undefined
.
getUserConsentStatus(purpose, vendor)
Deprecated, use getCurrentUserStatus instead.
Search the purpose in getCurrentUserStatus().purposes
or the vendor in getCurrentUserStatus().vendors
.
Check if the current user has given consent for a specific purpose and vendor.
Parameters
Name | Type | Description |
purpose |
| The purpose that we are checking the user consent for (example: |
vendor |
| The ID of vendor whose user consent is being checked for. If you are checking an IAB vendor, use an integer instead of a string. Custom vendor IDs must be prefixed with |
Returns
A boolean
that indicates if the user has given consent or not.
The method always returns true
if the specified purpose is an essential purpose and if the specified vendor has consent.
Example
getUserConsentStatusForPurpose(purposeId)
Deprecated, use getCurrentUserStatus instead.
Search the purposeId in getCurrentUserStatus().purposes
Get the user consent status for a given purpose.
Parameters
Name | Type | Description |
---|---|---|
purposeId |
| The ID of purpose that to check the user consent for. |
Returns
A boolean
that indicates if the user has given consent or not to the specific purpose.
undefined
is returned if the consent status is not known yet. From a GDPR perspective, you'll want to treat undefined
as false
(ie no consent given) but it is helpful to know that the user has not interacted with the consent UI yet so that you can subscribe to events and wait for consent information to be collected.
The method always returns true
if the specified purpose is an essential purpose.
Example
getUserConsentStatusForVendor(vendor)
Deprecated, use getCurrentUserStatus instead.
Search the vendorId in getCurrentUserStatus().vendors
.
Get the user consent status for a given vendor. We use the list of purposes declared for the vendor to make sure that it has consent for all of them. The required purposes are automatically setup for IAB or Didomi vendors and you must specify the required purposes for your custom vendors when configuring the tag.
When determining user consent status for a given vendor, the method will treat essential purposes as purposes with given consent.
Parameters
Name | Type | Description |
---|---|---|
vendor |
| The ID of the vendor whose user consent is being checked for. If you are checking an IAB vendor, use an integer instead of a string. Custom vendor IDs must be prefixed with |
Returns
A boolean
that indicates if the user has given consent or not to the specific vendor and all the purposes that require consent for that vendor.
undefined
is returned if the consent status is not known yet. From a GDPR perspective, you'll want to treat undefined
as false
(ie no consent given) but it is helpful to know that the user has not interacted with the consent UI yet so that you can subscribe to events and wait for consent information to be collected.
Example
getUserStatus()
Deprecated, use getCurrentUserStatus instead.
Search the purposes in getCurrentUserStatus().purposes
or the vendors in getCurrentUserStatus().vendors
.
Get the user consent and legitimate interest status for all the purposes and vendors.
Parameters
No parameter.
Returns
An object with the consent and legitimate interest status of the user for every purpose and vendor. The response also contains the user ID from Didomi (user_id
), the TCF consent string (consent_string
), additional consent string from Google's additional consent mode (addtl_consent
) and the dates of the user choices (created
and updated
ISO8061 dates).
It returns an object with the following information:
Consent and LI status for purposes
Consent and LI status for vendors
Computed global status for vendors (based on the required purposes for that vendor)
User ID
TCF consent string
Additional consent string
User creation date
User update date
User sync date
Example
isConsentRequired()
Deprecated, use getCurrentUserStatus().regulation
Determine if consent is required for the user based on two rules:
You are an EU company and collect consent for all visitors. In that case, consent is always required.
You are not an EU company and you only need to collect consent for EU visitors (see Country and GDPR for more information). In this case, we use the geolocation of the user to determine whether GDPR applies or not. For instance, a user in France or Germany will require consent (under the GDPR) whereas a user in the United States will not.
If you do not apply GDPR to all your visitors, you should call this function to determine whether you need to condition the loading of vendors or not.
Parameters
No parameter.
Returns
Boolean
Example
isUserConsentStatusPartial()
Deprecated, use isUserStatusPartial instead.
Determine if all consent information is available for the user.
This function returns true
if and only if:
Consent is required for the user (ie the user is in the EU or your tag is configured to apply GDPR to all users)
At least one vendor is configured (if there is no vendor configured, this function always returns
false
as there is no consent to collect)We are missing consent information for at least one vendor or purpose.
The consent re-collection window as configured in your tag has expired.
If there is at least one piece of consent information missing for a single vendor/purpose, this function will return true
. The consent notice is usually displayed when this function returns true
although there is no guarantee of the direct mapping between the two.
An important edge case is when you add new vendors or if configured vendors ask for new purposes: the consent notice will be displayed again and this function will return true
until the user has given or denied consent. Vendors that already had consent before will still operate normally as we only recollect consent for additional vendors/purposes.
Parameters
No parameter.
Returns
Boolean
Example
openTransaction()
Deprecated, use openCurrentUserTransaction instead.
Allow you to easily enable/disable a purpose/vendor from the existing consents.
Parameters
No parameter.
Returns
a Transaction
object that contain the current consents. You can then modify them with the functions below.
Example
setUserStatus(parameters)
Deprecated, use setCurrentUserStatus instead.
Sets the user consent and legitimate interest statuses for vendors and purposes. You must pass the full list of enabled/disabled purposes/vendors as it will override the previous consent and legitimate interest statuses. To get the current user status, you can use Didomi.getCurrentUserStatus()
Please read our article on what to expect from your analytics when setting a custom behavior for your consent notice.
Parameters
Parameters is an object with the following structure:
Name | Type | Description |
---|---|---|
|
| The list of IDs of purposes enabled for the consent legal basis |
|
| The list of IDs of purposes disabled for the consent legal basis |
|
| The list of IDs of purposes enabled for the legitimate interest legal basis |
|
| The list of IDs of purposes disabled for the legitimate interest legal basis |
|
| The list of IDs of vendors enabled for the consent legal basis |
|
| The list of IDs of vendors disabled for the consent legal basis |
|
| The list of IDs of vendors enabled for the legitimate interest legal basis |
|
| The list of IDs of vendors disabled for the legitimate interest legal basis |
|
| An optional ISO8601 date which represents the date when the consent was created |
|
| An optional ISO8601 date which represents the date when the consent was last updated |
|
| Action which triggered user status change |
Returns
Nothing
Example
setUserStatusForAll(params)
Deprecated, use setCurrentUserStatus instead.
Sets the user consent and legitimate interest statuses for all vendors and purposes. This method overrides the previous consent and legitimate interest statuses. To get the current user status, you can use Didomi.getCurrentUserStatus()
Please read our article on what to expect from your analytics when setting a custom behavior for your consent notice.
Parameters
Parameters is an object with the following structure:
Name | Type | Description |
---|---|---|
|
| Boolean value specifying whether all purposes' consents should be enabled or disabled |
|
| Boolean value specifying whether all purposes' legitimate interests should be enabled or disabled |
|
| Boolean value specifying whether all vendors' consents should be enabled or disabled |
|
| Boolean value specifying whether all vendors' legitimate interests should be enabled or disabled |
|
| An optional ISO8601 date which represents the date when the consent was created |
|
| An optional ISO8601 date which represents the date when the consent was last updated |
|
| Action which triggered user status change |
Returns
Nothing
Example
shouldConsentBeCollected()
Deprecated, use shouldUserStatusBeCollected instead.
Determine if consent should be collected for the visitor. Returns true
if consent is required for the current user and one of following two conditions is met:
Consent has never been collected for this visitor yet
New consents should be collected (as new vendors have been added) AND the number of days before recollecting them has exceeded
If none of these two conditions is met, the function returns false
.
This function is mainly present to allow you to know when to display your own notice if you have disabled our standard notice.
Parameters
No parameter.
Returns
Boolean
Example
CCPA
setDoNotSellStatus(status)
Set the Do Not Sell status of the user.
Parameters
Name | Type | Description |
---|---|---|
status |
|
|
Returns
Nothing
Example
getDoNotSellStatus()
Get the Do Not Sell status of the user.
Parameters
No parameter.
Returns
Boolean
Example
Last updated