Skip to main content
Configure the SDK by chaining CollectOption() builder methods, then call .build() to produce the Option you pass to Collect.initialize(option:).
let collectOptions = CollectOption()
  .writeKey(value: "YOUR_WRITE_KEY")
  .useConsent(value: true)
  .checkForCMP(value: true)
  .hashIdentities(value: true)
  .userCountry(code: "DEU")
  .build()

Collect.initialize(option: collectOptions)

Core options

MethodTypeDefaultDescription
writeKey(value: String)StringWrite key from the iOS Source.
logging(value: Bool)BoolfalseIf true, displays info / debug / warning / error logs. Otherwise only warning + error.
optOut(value: Bool)BoolfalseMaster kill switch. If true, no events are posted to SPL. Used as a fallback when consent is not used.
MethodTypeDefaultDescription
useConsent(value: Bool)BoolfalseIf true, the SDK waits for a consent signal before recording events.
checkForCMP(value: Bool)BoolfalseIf true (with useConsent), the SDK reads the TCF 2.0 CMP data stored by other CMPs to manage consent.
checkZeotapVendorConsent(value: Bool)BoolfalseIf true, the SDK requires Zeotap Vendor consent when resolving GDPR consent. If false, Zeotap Vendor consent is ignored.
purposesForTracking(value: [Int])[Int][1, 3, 4]TCF purpose IDs that gate tracking. See the TCF policies appendix.
purposesForIdentifying(value: [Int])[Int][1, 9]TCF purpose IDs that gate identification.
For the full consent walkthrough see Consent Resolution.

Identity & hashing

MethodTypeDefaultDescription
areIdentitiesHashed(value: Bool)BoolfalseSet true if your setUserIdentities calls already supply hashed PII keys (email_sha256_lowercase, etc.).
hashIdentities(value: Bool)BoolfalseIf true, raw PII passed to setUserIdentities is hashed by the SDK before being sent.
Both flags apply only to PII fields. Custom identities (crmID, visitorID, etc.) are always sent as-is.

Event delivery

MethodTypeDefaultDescription
batchSize(value: Int)Int30Maximum events allowed in the unsent queue before the next batch dispatches immediately.
maxCacheSize(value: Int)Int100Maximum events stored in local memory during network failures or delayed consent. Max value 200.
eventUploadInterval(value: Int)Int90If the queue is below the batch threshold, the next dispatch is scheduled after this many seconds.

Region

MethodTypeDefaultDescription
userCountry(code: String)StringnilAlpha-ISO3 country code sent as user.user_country. Determines storage region. Defaults to IP-derived country when omitted.

A complete example

let collectOptions = CollectOption()
  .writeKey(value: "YOUR_WRITE_KEY")
  .logging(value: false)
  .useConsent(value: true)
  .checkForCMP(value: false)        // custom consent flow
  .hashIdentities(value: true)
  .areIdentitiesHashed(value: false)
  .batchSize(value: 30)
  .maxCacheSize(value: 100)
  .eventUploadInterval(value: 90)
  .userCountry(code: "DEU")
  .purposesForTracking(value: [1, 3, 4])
  .purposesForIdentifying(value: [1, 9])
  .build()

Collect.initialize(option: collectOptions)
Last modified on June 22, 2026