Skip to main content
The iOS SDK has three consent strategies. Pick one at CollectOption time; the SDK uses it for:
  • User identification
  • Tracking user data
Consent decisions are persisted in UserDefaults 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.
let opts = CollectOption()
  .writeKey(value: "YOUR_WRITE_KEY")
  .optOut(value: false)
  .build()
MethodTypeValueDescription
optOut(value: Bool)BoolfalseExplicit 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 data from UserDefaults and queries the consent string before recording events.
let opts = CollectOption()
  .writeKey(value: "YOUR_WRITE_KEY")
  .useConsent(value: true)
  .checkForCMP(value: true)
  .purposesForTracking(value: [1, 3, 4])
  .purposesForIdentifying(value: [1, 9])
  .build()
MethodTypeValueDescription
useConsent(value: Bool)BooltrueSDK waits for a consent signal before recording.
checkForCMP(value: Bool)BooltrueReads TCF 2.0 variables from UserDefaults. Set false to use setConsent instead.
checkZeotapVendorConsent(value: Bool)Booltrue/falseIf true, the SDK requires Zeotap Vendor consent when resolving GDPR consent. Default false.
purposesForTracking(value: [Int])[Int][1, 3, 4]TCF purpose IDs that gate tracking.
purposesForIdentifying(value: [Int])[Int][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 over consent — no optOut shortcut, no TCF API. Supply consent explicitly via setConsent.
let opts = CollectOption()
  .writeKey(value: "YOUR_WRITE_KEY")
  .useConsent(value: true)
  .checkForCMP(value: false)
  .build()

// Later, when the user decides:
Collect.getInstance()?.setConsent(consent: [
  "track": true,
  "identify": true
])
The decision is stored in UserDefaults and replayed on every subsequent event until a new setConsent call overrides it.
KeyTypeDescription
trackBooltrue to allow event tracking.
identifyBooltrue 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(action: { _ in
  // show your consent banner / dialog
})

Granular signaling

You don’t have to grant all signals together. Set them independently:
// User wants tracking but not identification
Collect.getInstance()?.setConsent(consent: [
  "track": true,
  "identify": false
])
Brand-specific consent (e.g. zeotapVendorConsent, xyzVendorConsent) is honored under any consent strategy and persists across events:
Collect.getInstance()?.setConsent(consent: [
  "zeotapVendorConsent": true,
  "xyzVendorConsent": false
])
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