Opt-in and opt-out
Control tracking consent across all Zeta SDKs.
This page is for developers managing user tracking consent. It explains what opt-in and opt-out control, how to configure consent at initialization and at runtime, and what happens to SDK behavior in each state.
On this page
- What opt-in / opt-out controls
- How to opt out
- What happens on opt-out
- How to opt in
- Re-opt-in behavior
- Configuration vs runtime consistency
What opt-in / opt-out controls
The opt-in / opt-out setting controls whether the SDK:
- Collects and sends events to the ZMP backend.
- Updates user properties.
- Communicates with the backend for any purpose (event delivery, message polling, inbox sync).
When opted out, the SDK is effectively dormant. When opted in, normal SDK operation resumes.
How to opt out
You can opt out in two ways: through the initialization configuration or at runtime.
1. Configuration at initialization
Pass optIn: false in the ZTConfig when you initialize the SDK. The SDK starts in an opted-out state and does not send any data.
iOS (Swift)
let config = ZTConfig(
clientSiteId: "your-site-id",
clientSecret: "your-secret",
region: .US,
optIn: false
)
ZetaClient.shared.initialize(config: config)
For Objective-C, see iOS Getting Started.
Android (Kotlin)
val config = ZTConfig(
clientSiteId = "your-site-id",
optIn = false,
region = ZTRegion.US,
appEnvironment = ZTAppEnvironment.PRODUCTION
)
ZetaClient.initialize(applicationContext, config)
For Java, see Android Getting Started.
2. Runtime opt-out
Call the opt-out method at any point after initialization.
iOS (Swift)
ZetaClient.shared.optOutFromTracking()
For Objective-C, see iOS Getting Started.
Android (Kotlin)
ZetaClient.optOutFromTracking(applicationContext)
For Java, see Android Getting Started.
What happens on opt-out
Once opted out, the SDK:
- Immediately stops all backend communication. No events, user property updates, or message polls are sent.
- Clears cached data in the local database. Events queued for delivery and cached user data are discarded.
- Does not process incoming push messages. The SDK ignores push notifications delivered while in the opted-out state.
Important: The opt-out status is local only. The backend is not informed of the opt-out and may still attempt push notification delivery. The SDK does not process those notifications while opted out.
How to opt in
You can opt in through the initialization configuration or at runtime.
1. Configuration at initialization
Pass optIn: true in the ZTConfig to start the SDK in an opted-in state.
2. Runtime opt-in
Call the opt-in method to resume tracking.
iOS (Swift)
ZetaClient.shared.optInForTracking(uid: "user-123")
For Objective-C, see iOS Getting Started.
Android (Kotlin)
ZetaClient.optInForTracking(uid = "user-123")
For Java, see Android Getting Started.
The uid parameter is optional. If you do not provide a user ID, the SDK treats the user as anonymous.
Re-opt-in behavior
When a user opts back in after being opted out, the SDK treats it as a fresh launch. All cached data was cleared at opt-out time, so the SDK starts with a clean state -- new BSIN assignment, new session, and no historical event queue.
Configuration vs runtime consistency
If your app uses the runtime optInForTracking() / optOutFromTracking() methods, you must pass the same opt-in status through ZTConfig on the next app launch. If you do not, the ZTConfig value overwrites the runtime status.
For example, if a user opts out at runtime but you pass optIn: true in ZTConfig on the next launch, the SDK re-enables tracking. To avoid this, persist the user's consent choice in your app and use it to set the optIn parameter in ZTConfig.
Warning: Mismatched configuration and runtime opt-in states can cause unexpected tracking behavior. Always synchronize the two.
See also
- Data & privacy (iOS) -- iOS privacy manifest and data collection.
- Data & privacy (Android) -- Android data safety and privacy.
- Platform support -- feature availability by platform and SDK version.
