Configure privacy and data collection

  • Latest Dynatrace
  • How-to guide
  • 1-min read
  • Published Jan 14, 2026

Dynatrace provides privacy settings that allow you to control the amount of data collected from your users. These settings help ensure compliance with data protection regulations such as GDPR while still providing valuable insights into application performance. OneAgent supports privacy-first data collection by allowing developers to configure the level of data collection and crash reporting based on user consent, control data collection levels, enable or disable crash reporting, and apply user privacy options dynamically at runtime.

Configure data collection levels

OneAgent supports three levels of data collection, defined by the DataCollectionLevel.

LevelDescription
OFFNo data is collected.
PERFORMANCECollects performance-related data, such as app crashes and ANRs.
USER_BEHAVIORCollects both performance data and user behavior data, such as user actions.

Set the data collection level

Configure the data collection level using the applyUserPrivacyOptions API.

import com.dynatrace.android.agent.Dynatrace
import com.dynatrace.android.agent.conf.UserPrivacyOptions
import com.dynatrace.android.agent.conf.DataCollectionLevel
val privacyOptions = Dynatrace.getUserPrivacyOptions()
val updatedOptions = privacyOptions.newBuilder()
.withDataCollectionLevel(DataCollectionLevel.PERFORMANCE)
.build()
Dynatrace.applyUserPrivacyOptions(updatedOptions)

Enable or disable crash reporting

Crash reporting is enabled by default but can be controlled dynamically based on user consent. When enabled, OneAgent collects crash data to help developers diagnose and fix issues in their applications.

Use the applyUserPrivacyOptions API to enable or disable crash reporting:

import com.dynatrace.android.agent.Dynatrace
import com.dynatrace.android.agent.conf.UserPrivacyOptions
val privacyOptions = Dynatrace.getUserPrivacyOptions()
val updatedOptions = privacyOptions.newBuilder()
.withCrashReportingOptedIn(true) // Enable crash reporting
.build()
Dynatrace.applyUserPrivacyOptions(updatedOptions)

Apply privacy options

The applyUserPrivacyOptions API allows you to dynamically update privacy settings at runtime. This is useful for implementing user consent dialogs or privacy settings screens.

import com.dynatrace.android.agent.Dynatrace
import com.dynatrace.android.agent.conf.UserPrivacyOptions
import com.dynatrace.android.agent.conf.DataCollectionLevel
val privacyOptions = Dynatrace.getUserPrivacyOptions()
val updatedOptions = privacyOptions.newBuilder()
.withDataCollectionLevel(DataCollectionLevel.USER_BEHAVIOR)
.withCrashReportingOptedIn(false)
.build()
Dynatrace.applyUserPrivacyOptions(updatedOptions)

Implement user opt-in mode

The User Opt-In feature allows developers to comply with privacy regulations by explicitly obtaining user consent before collecting data or enabling crash reporting. This feature ensures that users have control over their data and can make informed decisions about their privacy.

How user opt-in works

When the User Opt-In feature is enabled, OneAgent does not collect any data or enable crash reporting until the user explicitly provides consent. Developers can use the applyUserPrivacyOptions API to update the privacy settings based on the user's preferences.

Default behavior

If the User Opt-In feature is not implemented, OneAgent defaults to the following settings:

  • Data Collection Level: OFF.
  • Crash Reporting: Disabled.

By implementing the User Opt-In feature, developers can ensure compliance with privacy regulations and provide users with greater control over their data.

Enable user opt-in mode

To enable user opt-in mode, update your Gradle configuration:

Gradle plugin configuration:

dynatrace {
configurations {
defaultConfig {
userOptIn true
}
}
}

Manual startup configuration:

DynatraceConfigurationBuilder("<YourApplicationID>", "<ProvidedBeaconURL>")
.withUserOptIn(true)
.buildConfiguration()

Dynatrace doesn't provide a consent dialog UI. You must implement your own consent banner or dialog within your application. The dialog should:

  1. Explain what data will be collected.
  2. Allow users to choose their preferred data collection level.
  3. Allow users to enable or disable crash reporting.
  4. Provide a way for users to change their preferences later.

Learn more

For more information about privacy and security settings, refer to:

Related tags
Digital Experience