# mParticle

{% hint style="success" %}
**Available for:** Consent Management Platform (CMP)
{% endhint %}

## How It Works

Thanks to the Didomi-mParticle integration, you will be able to collect consent data and push it to mParticle. At the same time, user consent data will continue streaming to Didomi via the Didomi SDK.

* mParticle SDK is initialized → and will automatically initialize the Didomi SDK → the consent notice is then displayed on your website
* Once the user provides/updates their consent on the Didomi consent notice, the consent data will be streamed:
  * To the Didomi server via the Didomi SDK
  * To the mParticle server via the mParticle SDK

<figure><img src="/files/FHCYuwhg9QttLO5lVqKF" alt=""><figcaption></figcaption></figure>

## Implementation

The Didomi-mParticle integration can be set up in 3 main steps:

### 1- Add the mParticle SDK

More documentation here: <https://docs.mparticle.com/developers/quickstart/web/overview/>

Add the mParticle SDK right below the opening \<head> in your webpage’s HTML. Don’t forget to replace the API key as indicated in the script.

```json
<script type="text/javascript">

// Configures the SDK. Note the settings below for isDevelopmentMode
// and logLevel.

window.mParticle = {
  config: {
    isDevelopmentMode: true,
    logLevel: "verbose"
  },
};

// Insert your API key below
(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=Array.prototype.slice.call(arguments);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>")+".mparticle.com/js/v2/"+t+"/mparticle.js" + dbUrl;var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(mp,c)})
("<REPLACE WITH API KEY>");

</script>
```

### 2- Add the Didomi SDK

Insert the Didomi SDK right below the mParticle SDK. More documentation on Didomi’s Web SDK can be found in [this developer documentation](https://developers.didomi.io/cmp/web-sdk).

### 3- Enable and Configure the integration in mParticle

#### **Set up the Didomi Integration**

1. Login to your mParticle app
2. Navigate to Directory → Didomi\\

   <figure><img src="/files/FRyMfbgxLcWcjVx8vXnp" alt=""><figcaption></figcaption></figure>
3. Click Setup → this will create your Event output for Didomi.

#### **Configure the Didomi-mParticle connection**

1. Navigate to Connections → connect
2. Choose your input: JS Web
3. Click Connect Output\\

   <figure><img src="/files/noFCKCj6vByvzSbnAFD3" alt=""><figcaption></figcaption></figure>
4. Choose your output: Didomi integration
5. Select a configuration from the list and click Next:\\

   <figure><img src="/files/A4rWXeYDdrfDxmikgAQm" alt=""><figcaption></figcaption></figure>
6. Connect Didomi-mParticle data transfer: select the mParticle purposes created earlier and map them to their corresponding Didomi purposes. Didomi purposes will be referenced thanks to the **purpose SDK ID** (from the Didomi console)

   <figure><img src="/files/gzcB53fZo941isOOLE8O" alt=""><figcaption></figcaption></figure>
7. Remove mapping for the other types of data (vendors)
8. Click “Add connection”


---

# 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/integrations/third-party-apps/didomi-mparticle-integration-for-your-cmp.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.
