> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kameleoon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OneTrust

> Integrate OneTrust CMP with Kameleoon to automatically activate or deactivate experiments and personalizations based on visitor consent status.

OneTrust is a platform that focuses privacy and security & governance. Customers use OneTrust to build integrated programs that comply with the CCPA, GDPR, LGPD, PDPA, ISO27001, and hundreds of the world's privacy and security laws.

This guide walks you through how to set up an integration with OneTrust CMP.

<Note>
  [Kameleoon is also IAB TCF compliant](./iab-transparency-and-consent-framework)
</Note>

## Integration with OneTrust CMP

Kameleoon provides a custom integration with OneTrust CMP. Kameleoon automatically reads the consent policy within the OneTrust platform for both our experimentation and personalization modules.

## Enable OneTrust integration on Kameleoon

First, you must add Kameleoon in OneTrust's CMP.

### Configure OneTrust in Kameleoon

<Warning>
  The Kameleoon snippet needs to be triggered independently of OneTrust and added directly to the page's source code to prevent flickering in your experiments and personalizations.
</Warning>

1. Log in to your Kameleoon account.
2. Click **Admin** > **Projects**.
3. Click **Configuration** on your project's card.

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/integrations/as-a-source/cmp/onetrust/Capture-décran-2021-05-10-à-14.44.41-1.png)
</Frame>

4. Unfold the **General** section.

#### Global custom script

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/integrations/as-a-source/cmp/onetrust/Capture-décran-2021-05-10-à-16.47.55.png)
</Frame>

The **Global custom script** insert links Kameleoon to OneTrust. Any JavaScript code you add in this insert will be executed every time the page is loaded. This feature is often used to add complex tracking code or integrations to other solutions.

To activate the bridge between Kameleoon and OneTrust, copy and paste the code below into the **Global script** section:

```javascript theme={null}
Kameleoon.API.Core.runWhenConditionTrue(
     () => window.OneTrust && window.OneTrust.OnConsentChanged && window.OnetrustActiveGroups,
     () => {
         Kameleoon.API.Visitor.personalizationLegalConsent || -1 === window.OnetrustActiveGroups.indexOf("**C0003**") || (console.log("[KAMELEOON ENABLE CONSENT] basic state"), Kameleoon.API.Core.enableLegalConsent("BOTH")),
             window.OneTrust.OnConsentChanged(({ detail: e }) => {
                 e &&
                     (e.includes("**C0003**")
                         ? (console.log("[KAMELEOON ENABLE CONSENT] consent changed"), Kameleoon.API.Core.enableLegalConsent("BOTH"))
                         : (console.log("[KAMELEOON DISABLE CONSENT] consent changed"), Kameleoon.API.Core.disableLegalConsent("BOTH")));
             });
     }
 );
```

You will need to update the code above depending on the category where Kameleoon has been added in Onetrust. For example, you may have a group called "Performance Cookies," which has a category id of `C0002`.

With this code, any time a visitor activates or disables Kameleoon's consent from the OneTrust pop-in, Kameleoon is automatically notified, and will activate or deactivate the Experiment or Personalization module (depending on whether the consent is granted or not).

Click **Validate** to apply the changes to your configuration.

#### Consent policy

The last step is setting your project's consent management policy to **Consent required** for both Experiment and Personalization. Please read [this documentation](../../../project-management/consent-management-policy) to find out more.

<Frame>
  ![](https://storage.googleapis.com/kameleoon-storage-documentation/user-manual/images/integrations/as-a-source/cmp/onetrust/Capture-décran-2021-05-10-à-16.51.09.png)
</Frame>

To do this:

1. Unfold the **Experiment** and/or **Personalization** section of your configuration.
2. Select the **Consent required** option in the dropdown.
3. Click **Validate** to apply your changes

Kameleoon will now collect and store data based on the consent provided by users from OneTrust CMP.
