Capture Behavior Data
Version 3.x
Version 2.x
Post Data from an Authenticated Server-to-Server Connection
Post Data from an Unauthenticated Server-to-Server Connection
The Engagement Mobile SDK provides a comprehensive, managed solution for handling user consent regarding the collection and transmission of event data. This feature is essential for compliance with privacy regulations such as GDPR, CCPA, and other regional privacy laws that require explicit user consent before collecting personal data.
Your mobile application is responsible for:
The SDK automatically manages data collection behavior based on the consent state you set, ensuring compliance and providing a seamless user experience.
This table describes the Data 360 Module consent states.
| iOS Values | Android Values | Description |
|---|---|---|
Consent.optIn | Consent.OPT_IN | In this state, events are transmitted to the configured Data 360 endpoint for collection. If queued events are present, the Data 360 Module transmits them immediately to Data 360. |
Consent.optOut | Consent.OPT_OUT | In this state, events created by the mobile application are ignored by the SDK. The events are never queued or transmitted off the device. If queued events are present, the Data 360 Module deletes them from memory. |
Consent.pending | Consent.PENDING | The default consent value for a newly initialized Data 360 Module. This state cannot be set manually — it is managed by the SDK. Only optIn and optOut can be assigned. See the platform-specific behavior below. |
The pending state behaves differently on each platform:
optIn is set, a new deviceId is generated and the SDK begins transmitting.The Data 360 Module can’t transmit events from a mobile device to Data 360 until the mobile application has collected customer consent for data collection.
If no prior consent has been set, then the initial state is pending. See the consent states table for platform-specific behavior during the pending state. If consent is granted, events begin transmitting to Data 360 (on Android, any queued events are flushed). If revoked, any queued events are deleted.
1import Cdp
2
3// when a user consents to data collection — property style
4CdpModule.shared.consent = .optIn
5
6// when a user does not consent to data collection — property style
7CdpModule.shared.consent = .optOut
8
9// method style (equivalent; also Objective-C compatible)
10CdpModule.shared.setConsent(consent: .optIn)1import com.salesforce.marketingcloud.cdp.CdpSdk
2import com.salesforce.marketingcloud.cdp.consent.Consent
3
4// when a user consents to data collection
5CdpSdk.requestSdk { sdk -> sdk.consent = Consent.OPT_IN }
6
7// when a user does not consent to data collection
8CdpSdk.requestSdk { sdk -> sdk.consent = Consent.OPT_OUT }
9
10// Consent.PENDING cannot be set manually — attempting to assign it
11// throws an IllegalArgumentExceptionAccess the current state of consent in the Data 360 Module:
1let consent = CdpModule.shared.getConsent()1CdpSdk.requestSdk { sdk ->
2 val consent = sdk.consent
3}