OneTrust is a global leader for GDPR and privacy management.

mParticle’s OneTrust integration operates in a unique way. While it is enabled as an event integration, no event data is passed from mParticle to OneTrust. The purpose of the integration is to allow you to map OneTrust groups to mParticle’s consent “purposes”.

mParticle can, in turn, use this consent information to enable and disable other integrations, power consent forwarding rules, etc. Read our documentation on Consent Management to understand more about consent purposes.

Enabling the Integration

The OneTrust integration works by syncing consent state between the current mParticle user and OneTrust SDK. You must separately initialize the OneTrust SDK and the mParticle SDK, and the integration simply works as a bridge between the two.

The flow is as follows:

  1. Both SDKs are separately initialized.
  2. The mParticle SDK will detect and initialize the OneTrust kit if present.
  3. Whenever (a) consent state of the current user is mutated, or (b) the current user changes based on an mParticle IDSync API result, the mParticle kit will send the latest OneTrust-gathered consent state to the mParticle SDK.

Before enabling the integration, include your customized script for OneTrust in the <head> of your page before the mParticle snippet. You can get this from your OneTrust dashboard under Preference & Consent Management > Cookie Compliance > Integrations > Scripts.

// OneTrust script from your admin dashboard

<!-- OneTrust Cookies Consent Notice start for YOURWEBSITENAME.COM -->
<script src=""  type="text/javascript" charset="UTF-8" data-domain-script="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" ></script>
<script type="text/javascript">
function OptanonWrapper() { }
<!-- OneTrust Cookies Consent Notice end for YOURWEBSITENAME.COM -->

// from Web Docs quickstart
    function(t){window.mParticle=window.mParticle||{};window.mParticle.EventType={Unknown:0,Navigation:1,Location:2,Search:3,Transaction:4,UserContent:5,UserPreference:6,Social:7,Other:8};window.mParticle.eCommerce={Cart:{}};window.mParticle.Identity={};window.mParticle.config=window.mParticle.config||{};window.mParticle.config.rq=[];window.mParticle.config.snippetVersion=2.3;window.mParticle.ready=function(t){window.mParticle.config.rq.push(t)};var e=["endSession","logError","logBaseEvent","logEvent","logForm","logLink","logPageView","setSessionAttribute","setAppName","setAppVersion","setOptOut","setPosition","startNewSession","startTrackingLocation","stopTrackingLocation"];var o=["setCurrencyCode","logCheckout"];var i=["identify","login","logout","modify"];e.forEach(function(t){window.mParticle[t]=n(t)});o.forEach(function(t){window.mParticle.eCommerce[t]=n(t,"eCommerce")});i.forEach(function(t){window.mParticle.Identity[t]=n(t,"Identity")});function n(e,o){return function(){if(o){e=o+"."+e}var;t.unshift(e);window.mParticle.config.rq.push(t)}}var dpId,dpV,config=window.mParticle.config,env=config.isDevelopmentMode?1:0,dbUrl="?env="+env,dataPlan=window.mParticle.config.dataPlan;dataPlan&&(dpId=dataPlan.planId,dpV=dataPlan.planVersion,dpId&&(dpV&&(dpV<1||dpV>1e3)&&(dpV=null),dbUrl+="&plan_id="+dpId+(dpV?"&plan_version="+dpV:"")));var mp=document.createElement("script");mp.type="text/javascript";mp.async=true;mp.src=("https:"==document.location.protocol?"https://jssdkcdns":"http://jssdkcdn")+""+t+"/mparticle.js" + dbUrl;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(mp,c)}


To enable the OneTrust integration, configure OneTrust from mParticle’s integrations directory and connect it to your Web input. In the Connection Settings, you need to map your OneTrust Cookie Group IDs to your mParticle consent purposes.

The ID of each of your Cookie Groups can be found in the OneTrust dashboard under Preference & Consent Management > Cookie Compliance > Categorizations > Categories.

In this example, OneTrust Cookie Group “group 2” (Performance Cookies) are mapped to the “Performance” purpose, and OneTrust Cookie Group “group 4” (Targeting Cookies) are mapped to the “Marketing” purpose:

How it Works

Whenever a user browses your site, OneTrust sets a OnetrustActiveGroups variable on the window. This variable is a comma-separated list of Cookie Groups the current user is part of. The value might look like "group 2, group 4".

When the OneTrust integration is enabled, the mParticle SDK checks the value of OnetrustActiveGroups and sets consent state for each mapped purpose. If the mapped Cookie Group ID is listed in OnetrustActiveGroups, mParticle will set the value of consented to true for the corresponding purpose. If the ID is not listed, mParticle sets consented to false.

For example, if your Cookie Groups are mapped as above, and the value of OnetrustActiveGroups is "group 2", mParticle will set consented to true for the “Performance” purpose and false for the “Marketing” purpose.

The mParticle SDK will automatically update consent state if the user changes, or if the value of OnetrustActiveGroups changes.

Connection Settings

Setting Name Data Type Platform Description
Consent Mapping string Web Mapping of your mParticle consent purposes to OneTrust consent groups.

Was this page helpful?