Use opt-out when a user must be fully excluded from tracking. The SDK stores the opt-out state and stops accepting further tracking data while opt-out is active.
Important
The SDK must already be initialized before you call these methods.
Methods
Method | Description |
|---|---|
| Enables or disables opt-out. When enabling opt-out, you can decide whether already cached requests should be sent first. |
| Returns whether opt-out is currently active. |
What happens when opt-out is enabled
The opt-out state is stored by the SDK.
Tracking is disabled for incoming requests.
Scheduled send jobs are cancelled.
If
sendCurrentDataistrue, cached requests are sent and then cleaned up.If
sendCurrentDataisfalse, cached requests are deleted immediately.
Examples
// Enable opt-out and delete cached data immediately
Webtrekk.getInstance().optOut(value = true, sendCurrentData = false)
// Enable opt-out but send cached data first
Webtrekk.getInstance().optOut(value = true, sendCurrentData = true)
// Disable opt-out and resume tracking
Webtrekk.getInstance().optOut(value = false)
// Check the current state
val isOptOutActive = Webtrekk.getInstance().hasOptOut()When to use it
Apply a privacy choice that requires full tracking exclusion.
Stop tracking immediately for a user at runtime.
Related pages: Anonymous Tracking, Immediate Data Send & Cleanup.