Cookie Consent Integration with Adobe Data Collection

This article outlines the recommended approach for implementing OneTrust’s Cookie Consent Management Platform (CMP) using Adobe Data Collection, formerly known as Adobe Launch.

To add event listeners your site

To configure the Adobe Data Collection tool

Deploying the CMP

Deploying the CMP within the Adobe Data Collection tool itself is optional, but it allows you to quickly deploy and update the CMP on sites where Adobe Data Collection has been implemented.

  1. Create a new rule in Adobe Data Collection.

  2. Set the rule to run on the Library Loaded (Page Top) event.



  3. Create a Custom Code action in the rule using the Core extension

  4. Set the Language inside the Custom Code action to HTML.



  5. Click the Open Editor button.

  6. Paste in your CMP code alongside the event listener code.

Configuring the Adobe Experience Cloud ID Service

  1. Add the Experience Cloud ID Service extension to your Adobe Data Collection property if it does not already exist.



  2. Enter your Marketing Cloud Organization ID, if not already configured.

    Tip:

    This is an alphanumeric value that ends with @AdobeOrg.

  3. Configure the Enable Opt In setting as Yes.

  4. Set the value of Previous Permissions to be %Opt In Permissions% to refer to your Opt In Permissions .

  5. For Pre Opt In Approvals, check whichever boxes apply to your consent model (if users have to opt-in to any category in order for cookies to be set, leave all boxes unchecked). In the text box in this section, set the value to %Baseline Consent% to refer to your Baseline Consent .

  6. Save the extension and publish when ready.



Setting Up Data Elements

There are a few data elements required to support the integration with OneTrust. Their purposes and configuration steps are outlined below. It is important to use the names specified below, otherwise you will have to manually ensure that all of the references to these names in the other data elements and code are also changed. All data elements are the Custom Code type unless otherwise specified.

This data element returns an array of the Adobe tools that should be opted into by default. In this example, all tools are opted out of by default. If you wish to change this, you will need to update the logic in this code to return true instead of false for the tools that you want users to be opted into by default.



JSON
var optInCategories = {
AAM: "aam",
ADCLOUD: "adcloud",
ANALYTICS: "aa",
CAMPAIGN: "campaign",
ECID: "ecid",
LIVEFYRE: "livefyre",
MEDIA_ANALYTICS: "mediaaa",
TARGET: "target"
};
var defaultToOff = {};
for (var key in optInCategories){
var thiskey = optInCategories[key];
defaultToOff[thiskey] = false;
}
return defaultToOff;

Opt In Groups

This data element returns an array of the groups that have been opted into by the user via the OneTrust CMP. It also provides for a manual override of the consented groups for testing purposes

Tip:

You can set OTgroups_override as an item in localStorage with a comma-separated list of the groups you want to show as enabled for the purpose of testing.



JAVASCRIPT
function removeItemAll(arr, value) {
var i = 0;
while (i < arr.length) {
if (arr[i].indexOf(value) >= 0) {
arr.splice(i, 1);
} else {
++i;
}
}
return arr;
}
try {
// Allow for manual override for testing
var groups_or = window.localStorage.getItem("OTgroups_override");
if(typeof(groups_or) != "undefined" && groups_or != null) {
groups_or = groups_or.replace(/:1/g, "").split(",");
removeItemAll(groups_or, ":");
if(Array.isArray(groups_or)) {
_satellite.logger.info("returning OT groups from override");
return groups_or;
} else {
_satellite.logger.info("returning *empty* OT groups from override");
return [];
}
}
// Get everything from the OptanonConsent cookie
var paramsString = _satellite.cookie.get("OptanonConsent");
if(typeof(paramsString) == "undefined") {
return [];
}
const consentParams = new URLSearchParams(paramsString);
// Throw the consent groups from the cookie into an array
var consentGroups = decodeURIComponent(consentParams.get("groups")).replace(/:1/g, "").split(",");
// Remove any that aren't enabled/set to opted in
removeItemAll(consentGroups, ":");
if(Array.isArray(consentGroups)) {
return consentGroups;
} else {
return [];
}
} catch(e) {
_satellite.logger.warn("unable to parse consent groups from onetrust cookie: " + e.message);
}

Opt In Permissions

This data element updates the status of permissions in Adobe based on what categories have been opted into per the OneTrust CMP. You will need to update the values in the indexOf() function calls on lines 8 and 10 to match the identifiers for your performance and targeting consent groups, respectively.



JSON
_satellite.logger.info("updating opt-in permissions with ecid");


var OTgroups = _satellite.getVar("Opt In Groups");

var activeCategories = _satellite.getVar("Baseline Consent");

var optInCategories = {"AAM":"aam","ADCLOUD":"adcloud","ANALYTICS":"aa","CAMPAIGN":"campaign","ECID":"ecid","LIVEFYRE":"livefyre","TARGET":"target","MEDIA_ANALYTICS":"mediaaa"};

for (var key in optInCategories) {

/* implement temporary workaround for category 3 always being on */

if (OTgroups.indexOf('2') !== -1 && (key == "ANALYTICS" || key == "ECID")) {

activeCategories[adobe.OptInCategories[key]] = true;

} else if (OTgroups.indexOf('4') !== -1 && (key == "AAM" || key == "TARGET" || key == "ECID")) {

activeCategories[adobe.OptInCategories[key]] = true;

} else {

activeCategories[adobe.OptInCategories[key]] = false;

}

}

window._otadobe = window._otadobe || {};

window._otadobe.consent = activeCategories;

return activeCategories;

Functional/Targeting/Performance Cookies Allowed

This is a set of data elements that correspond to the consent categories configured in your OneTrust CMP tenant. If you use different categories, create different data elements to match your categories.

Each of these data elements will have a single line of custom code that returns true or false depending on whether or not a specific consent group is opted into by the user. In the following example, change the number 3 in the code to match the identifier for the consent group for each data element you create.

CODE
return _satellite.getVar("Opt In Groups").indexOf("3") >= 0;


Configuring Tag Rules

Once the data elements above have all been created, you have finished laying the foundation for managing consent in Adobe Data Collection. The only remaining step is to implement conditions in each rule that correspond to the consent categories that apply to that rule. For example, a rule that is tracking something in Adobe Analytics would likely use the Performance Cookies Allowed data element as a condition.

  1. In a new or existing rule, click the Add icon under Conditions to add a new condition.

  2. Set the Condition Type to Value Comparison.

  3. Set the Name to whichever data element you want to use for the condition (e.g., Performance Cookies Allowed).

  4. For Left Operand, specify the data element that corresponds to the consent category that will apply to the rule. You can click the icon next to the field for a list of data elements for easy selection (example: %Performance Cookies Allowed%).

  5. For Operator, select Is True.



Repeat the above steps for each rule you want the OneTrust CMP to control.