Skip to main content
The Android SDK has three consent strategies. Pick one at CollectOptions time; the SDK uses it for:
  • User identification
  • Tracking user data
Consent decisions are persisted in SharedPreferences and replayed on subsequent events until changed.
For Default Opt-in and GDPR strategies, only brand consent is honored from setConsent — the primary track and identify fields are ignored. Primary fields apply only in Custom mode.

Default opt-in

Use this when you don’t have a CMP and consent is conveyed by your own server-side logic.
CollectOptions options = CollectOptions.builder(this)
  .credential("YOUR_WRITE_KEY")
  .optOut(false)
  .build();
MethodTypeValueDescription
optOut(value)BooleanfalseExplicit consent signal. When true, the SDK is fully suppressed.

GDPR TCF 2.0

Use this when your app integrates a TCF 2.0 CMP. The SDK reads the TCF variables from SharedPreferences and queries the consent string before recording events.
CollectOptions options = CollectOptions.builder(this)
  .credential("YOUR_WRITE_KEY")
  .useConsent(true)
  .checkForCMP(true)
  .purposesForTracking(Arrays.asList(1, 3, 4))
  .purposesForIdentifying(Arrays.asList(1, 9))
  .build();
MethodTypeValueDescription
useConsent(consent)BooleantrueSDK waits for a consent signal before recording.
checkForCMP(is_CMP_available)BooleantrueReads TCF 2.0 variables from SharedPreferences. Set false to use setConsent instead.
checkZeotapVendorConsent(boolean)Booleantrue/falseIf true, the SDK requires Zeotap Vendor consent when resolving GDPR consent. Default false.
purposesForTracking(tracking_ids)List<Integer>Arrays.asList(1, 3, 4)TCF purpose IDs that gate tracking.
purposesForIdentifying(identification_ids)List<Integer>Arrays.asList(1, 9)TCF purpose IDs that gate identification.
TCF purpose IDs are defined in the TCF policies appendix. Use this when you want full control — no optOut shortcut, no TCF API. Supply consent explicitly via setConsent.
CollectOptions options = CollectOptions.builder(this)
  .credential("YOUR_WRITE_KEY")
  .useConsent(true)
  .checkForCMP(false)
  .build();

// Later, when the user decides:
Map<String, Object> consent = new HashMap<>();
consent.put("track", true);
consent.put("identify", true);
Collect.getInstance().setConsent(consent);
The decision is stored in SharedPreferences and replayed on every subsequent event until a new setConsent call overrides it.
KeyTypeDescription
trackBooleantrue to allow event tracking.
identifyBooleantrue to allow user matching and third-party enrichment (e.g. zcookie, ID+).
If useConsent(true) and no consent is set yet, the SDK queues events and waits. Use listenToAskForConsent to trigger your consent UI:
Collect.getInstance().listenToAskForConsent(() -> {
  // show your consent banner / dialog
});

Granular signaling

You don’t have to grant all signals together. Set them independently:
Map<String, Object> consent = new HashMap<>();
consent.put("track", true);
consent.put("identify", false);
Collect.getInstance().setConsent(consent);
Brand-specific consent (e.g. zeotapVendorConsent, xyzVendorConsent) is honored under any consent strategy and persists across events:
Map<String, Object> brandConsent = new HashMap<>();
brandConsent.put("zeotapVendorConsent", true);
brandConsent.put("xyzVendorConsent", false);
Collect.getInstance().setConsent(brandConsent);
Under Default Opt-in and GDPR modes, only brand consent keys are honored — track and identify are ignored.

Choosing a strategy

Default opt-in

No CMP, simple control via optOut.

GDPR TCF 2.0

You already have a TCF 2.0 CMP in your app.

Custom

You want granular control and your own consent UI.
Last modified on June 22, 2026