Consent Management

mParticle’s Consent Management framework is designed to give brands the tools they need to manage their consent and privacy obligations under the European Union’s General Data Protection Regulation (GDPR).

Before instrumenting Consent State in your app, be sure to read our GDPR Consent Management Guide.

Consent state can be logged in the SDK using the Consent State API. Once a consent state is set, it cannot be modified. To change the consent state for a given purpose, you can either remove it, or replace it with a new complete consent state object.

var user = mParticle.Identity.getCurrentUser()
// Create consent 
var location_collection_consent = mParticle.Consent.createGDPRConsent(
    true, // Consented
    Date.now(), // Timestamp
    "location_collection_agreement_v4", // Document
    "17 Cherry Tree Lane", // Location
    "IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702" // Hardware ID
);

var parental_consent = mParticle.Consent.createGDPRConsent(
    false, // Consented
    Date.now(), // Timestamp
    "parental_consent_agreement_v2", // Document
    "17 Cherry Tree Lane", // Location
    "IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702" // Hardware ID
);

// Add to your consent state
var consentState = mParticle.Consent.createConsentState();
consentState.addGDPRConsentState("location_collection", location_collection_consent);
consentState.addGDPRConsentState("parental", parental_consent);
user.setConsentState(consentState);

// Remove consent state
consentState = user.getConsentState();
if(consentState) {
  if (consentState.getGDPRConsentState()["parental"]) {
    consentState.removeGDPRConsentState("parental");
    user.setConsentState(consentState);
  }
}