# Deprecated

## User Status

### getRequired**Vendor**Ids

Get the list of vendor IDs that are configured for the consent notice and that consent is collected for.

**Parameters**

No parameter.

**Returns**

An array of vendor IDs.

**Example**

```javascript
// Returns ['google']
Didomi.getRequiredVendorIds();
```

## GDPR

### \_\_cmp(command, parameter, callback)

Didomi is fully compliant with the CMP API from the [IAB Transparency and Consent framework version 1](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/CMP%20JS%20API%20v1.1%20Final.md#what-api-will-need-to-be-provided-by-the-cmp-).\
We expose a `__cmp` function and listen to `postMessage` events as per the specification.

Example (getting the IAB consent string):

```javascript
__cmp("getConsentData", null, function (result) {
  // The IAB consent string is available in the `consentData` property of the object
  console.log(result.consentData);
});
```

[Read more in the IAB documentation](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/CMP%20JS%20API%20v1.1%20Final.md#what-api-will-need-to-be-provided-by-the-cmp-)

{% hint style="warning" %}
The **\_\_cmp** function belongs to the IAB Transparency and Consent framework version 1, which is officially deprecated since **8/15/2020.**
{% endhint %}

### getObservableOnUserConsentStatusForVendor(vendorId)

**Deprecated**, use [addVendorStatusListener](https://developers.didomi.io/cmp/web-sdk/reference/api/..#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 | `string` | 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 `c:`. |

**Returns**

`Observable` on the consent status of the vendor.

{% hint style="warning" %}
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.
{% endhint %}

**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.

```javascript
Didomi.getObservableOnUserConsentStatusForVendor("vendor-id").subscribe(
  function (consentStatus) {
    if (consentStatus === undefined) {
      // The consent status for the vendor is unknown
    } else if (consentStatus === true) {
      // The user has given consent to the vendor
    } else if (consentStatus === false) {
      // The user has denied consent to the vendor
    }
  },
);
```

**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.

```javascript
Didomi.getObservableOnUserConsentStatusForVendor("vendor-id")
  .filter(function (status) {
    return status !== undefined;
  })
  .subscribe(function (consentStatus) {
    if (consentStatus === undefined) {
      // The consent status for the vendor is unknown
    } else if (consentStatus === true) {
      // The user has given consent to the vendor
    } else if (consentStatus === false) {
      // The user has denied consent to the vendor
    }
  });
```

**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.

```javascript
Didomi.getObservableOnUserConsentStatusForVendor("vendor-id")
  .first()
  .subscribe(function (consentStatus) {
    if (consentStatus === undefined) {
      // The consent status for the vendor is unknown
    } else if (consentStatus === true) {
      // The user has given consent to the vendor
    } else if (consentStatus === false) {
      // The user has denied consent to the vendor
    }
  });
```

**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`.

```javascript
Didomi.getObservableOnUserConsentStatusForVendor("vendor-id")
  .first()
  .filter(function (status) {
    return status !== undefined;
  })
  .subscribe(function (consentStatus) {
    if (consentStatus === true) {
      // The user has given consent to the vendor
    } else if (consentStatus === false) {
      // The user has denied consent to the vendor
    }
  });
```

### getUserConsentStatus(purpose, vendor)

**Deprecated**, use [getCurrentUserStatus](https://developers.didomi.io/cmp/web-sdk/reference/api/..#getcurrentuserstatus) instead.

{% hint style="info" %}
Search the purpose in `getCurrentUserStatus().purposes` or the vendor in `getCurrentUserStatus().vendors`.
{% endhint %}

Check if the current user has given consent for a specific purpose and vendor.

**Parameters**

<table data-header-hidden><thead><tr><th width="249.33333333333331">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>Name</td><td>Type</td><td>Description</td></tr><tr><td>purpose</td><td><code>string</code></td><td>The purpose that we are checking the user consent for (example: <code>cookies</code>)</td></tr><tr><td>vendor</td><td><code>string</code></td><td>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 <code>"c:"</code>.</td></tr></tbody></table>

**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**

```javascript
// IAB vendors
Didomi.getUserConsentStatus(Didomi.Purposes.Cookies, "1");

// Didomi vendors
Didomi.getUserConsentStatus(Didomi.Purposes.Cookies, "vendor-id");

// Custom vendors
Didomi.getUserConsentStatus(Didomi.Purposes.Cookies, "c:custom-vendor-id");
```

### getUserConsentStatusForPurpose(purposeId)

**Deprecated**, use [getCurrentUserStatus](https://developers.didomi.io/cmp/web-sdk/reference/api/..#getcurrentuserstatus) instead.

{% hint style="info" %}
Search the purposeId in `getCurrentUserStatus().purposes`
{% endhint %}

Get the user consent status for a given purpose.

**Parameters**

| Name      | Type     | Description                                           |
| --------- | -------- | ----------------------------------------------------- |
| purposeId | `string` | 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**

```javascript
Didomi.getUserConsentStatusForPurpose("cookies");
```

### getUserConsentStatusForVendor(vendor)

**Deprecated**, use [getCurrentUserStatus](https://developers.didomi.io/cmp/web-sdk/reference/api/..#getcurrentuserstatus) instead.

{% hint style="info" %}
Search the vendorId in `getCurrentUserStatus().vendors`.
{% endhint %}

\
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 | `string` | 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 `c:`. |

**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**

```javascript
// IAB vendors
Didomi.getUserConsentStatusForVendor("1");

// Didomi vendors
Didomi.getUserConsentStatusForVendor("vendor-id");

// Custom vendors
Didomi.getUserConsentStatusForVendor("c:custom-vendor-id");
```

### getUserStatus()

**Deprecated**, use [getCurrentUserStatus](https://developers.didomi.io/cmp/web-sdk/reference/api/..#getcurrentuserstatus) instead.

{% hint style="info" %}
Search the purposes in `getCurrentUserStatus().purposes` or the vendors in `getCurrentUserStatus().vendors`.
{% endhint %}

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](https://support.google.com/admanager/answer/9681920) (`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

```javascript
{
  purposes: {
      global: {
        enabled: ['purpose1'], // IDs of the purposes that are essential OR enabled as consent OR enabled as LI
        disabled: ['purpose2'] // All other purposes
      },
      consent: {
          enabled: ['purpose1'], // IDs of the purposes with consent enabled
          disabled: ['purpose2'] // IDs of the purposes with consent disabled
      },
      legitimate_interest: {
          enabled: ['purpose1'], // IDs of the purposes with legitimate interest enabled
          disabled: ['purpose2'] // IDs of the purposes with legitimate interest disabled
      },
      essential: ['purposexxx'], // IDs of the purposes that are defined as essential
  },
  vendors: {
      consent: {
          enabled: ['vendor1'], // IDs of the vendors with consent enabled
          disabled: ['vendor2'] // IDs of the vendors with consent disabled
      },
      legitimate_interest: {
          enabled: ['vendor1'], // IDs of the vendors with legitimate interest enabled
          disabled: ['vendor2'] // IDs of the vendors with legitimate interest disabled
      },
      global: {
          enabled: ['vendor1'], // IDs of the vendors that have been marked as enabled by the user based on consent/LI. When computing this property, required purposes are taken into account and essential purposes are considered as enabled.
          disabled: ['vendor2'] // All other vendors
      },
      global_consent: {
          enabled: ['vendor1'], // IDs of the vendors that have been marked as enabled by the user based on consent. When computing this property, required purposes are taken into account and essential purposes are considered as enabled.
          disabled: ['vendor2'] // All other vendors
      },
      global_li: {
          enabled: ['vendor1'], // IDs of the vendors that have been marked as enabled by the user based on LI. When computing this property, required purposes are taken into account and essential purposes are considered as enabled.
          disabled: ['vendor2'] // All other vendors
      }
  },
  user_id: 'user_id_from_token', // Didomi user ID
  created: 'ISO8061 creation date from token', // User choices creation date
  updated: 'ISO8061 update date from token', // User choices update date
  consent_string: '...' // TCF consent string,
  addtl_consent: '...' // Additional consent string
}
```

**Example**

```javascript
Didomi.getUserStatus();
```

### isConsentRequired()

**Deprecated**, use [getCurrentUserStatus().regulation](https://developers.didomi.io/cmp/web-sdk/reference/api/..#getcurrentuserstatus)

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](https://developers.didomi.io/cmp/consent-notice/notice#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.

{% hint style="info" %}
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.
{% endhint %}

**Parameters**

No parameter.

**Returns**

`Boolean`

**Example**

```javascript
Didomi.isConsentRequired();
```

### isUserConsentStatusPartial()

**Deprecated**, use [isUserStatusPartial](https://developers.didomi.io/cmp/web-sdk/reference/api/..#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**

```javascript
Didomi.isUserConsentStatusPartial();
```

### openTransaction()

**Deprecated**, use [openCurrentUserTransaction](https://developers.didomi.io/cmp/web-sdk/reference/api/..#opencurrentuserstatustransaction) 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**

<pre class="language-javascript"><code class="lang-javascript"><strong>const transaction = Didomi.openTransaction();
</strong>// enable a purpose
transaction.enablePurpose('cookies');
// enable purposes
transaction.enablePurposes('cookies', 'analytics');
// disable a purpose
transaction.disablePurpose('analytics');
// disable purposes
transaction.disablePurposes('cookies', 'analytics');
// enable a vendor
transaction.enableVendor(1);
// enable vendors
transaction.enableVendors(2, 3);
// disable a vendor
transaction.disableVendor(2);
// disable vendors
transaction.disableVendors(2, 3);
// Save and set the token/cookie with the new values
transaction.commit();
</code></pre>

### **setUserStatus**(parameters)

**Deprecated**, use [setCurrentUserStatus](https://developers.didomi.io/cmp/web-sdk/reference/api/..#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](https://support.didomi.io/analytics-with-a-custom-setup) 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                                                                          |
| --------------------------------------- | -------------- | ------------------------------------------------------------------------------------ |
| `purposes.consent.enabled`              | `array`        | The list of IDs of purposes enabled for the consent legal basis                      |
| `purposes.consent.disabled`             | `array`        | The list of IDs of purposes disabled for the consent legal basis                     |
| `purposes.legitimate_interest.enabled`  | `array`        | The list of IDs of purposes enabled for the legitimate interest legal basis          |
| `purposes.legitimate_interest.disabled` | `array`        | The list of IDs of purposes disabled for the legitimate interest legal basis         |
| `vendors.consent.enabled`               | `array`        | The list of IDs of vendors enabled for the consent legal basis                       |
| `vendors.consent.disabled`              | `array`        | The list of IDs of vendors disabled for the consent legal basis                      |
| `vendors.legitimate_interest.enabled`   | `array`        | The list of IDs of vendors enabled for the legitimate interest legal basis           |
| `vendors.legitimate_interest.disabled`  | `array`        | The list of IDs of vendors disabled for the legitimate interest legal basis          |
| `created`                               | `ISO8601 date` | An optional ISO8601 date which represents the date when the consent was created      |
| `updated`                               | `ISO8601 date` | An optional ISO8601 date which represents the date when the consent was last updated |
| `action`                                | `string`       | Action which triggered user status change                                            |

**Returns**

Nothing

**Example**

```javascript
Didomi.setUserStatus({
  purposes: {
    consent: {
      enabled: ["purpose1"], // IDs of the purposes with consent enabled
      disabled: ["purpose2"], // IDs of the purposes with consent disabled
    },
    legitimate_interest: {
      enabled: ["purpose1"], // IDs of the purposes with legitimate interest enabled
      disabled: ["purpose2"], // IDs of the purposes with legitimate interest disabled
    },
  },
  vendors: {
    consent: {
      enabled: ["vendor1"], // IDs of the vendors with consent enabled
      disabled: ["vendor2"], // IDs of the vendors with consent disabled
    },
    legitimate_interest: {
      enabled: ["vendor1"], // IDs of the vendors with legitimate interest enabled
      disabled: ["vendor2"], // IDs of the vendors with legitimate interest disabled
    },
  },
});
```

### setUserStatusForAll(params)

**Deprecated**, use [setCurrentUserStatus](https://developers.didomi.io/cmp/web-sdk/reference/api/..#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](https://support.didomi.io/analytics-with-a-custom-setup) 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                                                                                       |
| ----------------------- | -------------- | ------------------------------------------------------------------------------------------------- |
| `purposesConsentStatus` | `boolean`      | Boolean value specifying whether all purposes' consents should be enabled or disabled             |
| `purposesLIStatus`      | `boolean`      | Boolean value specifying whether all purposes' legitimate interests should be enabled or disabled |
| `vendorsConsentStatus`  | `boolean`      | Boolean value specifying whether all vendors' consents should be enabled or disabled              |
| `vendorsLIStatus`       | `boolean`      | Boolean value specifying whether all vendors' legitimate interests should be enabled or disabled  |
| `created`               | `ISO8601 date` | An optional ISO8601 date which represents the date when the consent was created                   |
| `updated`               | `ISO8601 date` | An optional ISO8601 date which represents the date when the consent was last updated              |
| `action`                | `string`       | Action which triggered user status change                                                         |

**Returns**

Nothing

**Example**

```javascript
Didomi.setUserStatusForAll({
  purposesConsentStatus: true,
  purposesLIStatus: true,
  vendorsConsentStatus: true,
  vendorsLIStatus: true,
  action: "click",
});
```

### shouldConsentBeCollected()

**Deprecated**, use [shouldUserStatusBeCollected](https://developers.didomi.io/cmp/web-sdk/reference/api/..#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**

```javascript
Didomi.shouldConsentBeCollected();
```

***

## CCPA

### setDoNotSellStatus(status)

Set the Do Not Sell status of the user.

**Parameters**

| Name   | Type      | Description                                                                                                                                           |
| ------ | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| status | `boolean` | <p><code>true</code> if the user has opted out of data sharing.</p><p><code>false</code> if the user has not opted out of data sharing (default).</p> |

**Returns**

Nothing

**Example**

```javascript
Didomi.CCPA.setDoNotSellStatus(true);
```

### getDoNotSellStatus()

Get the Do Not Sell status of the user.

**Parameters**

No parameter.

**Returns**

`Boolean`

**Example**

```javascript
Didomi.CCPA.getDoNotSellStatus();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.didomi.io/cmp/web-sdk/reference/api/deprecated.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
