Initialization options
You can pass user attributes when you initialize the SDK. On Android they go in a TapInitOptions object; on iOS they are parameters of initialize.
Configuration options
| Option | Description | Required? |
|---|---|---|
userAttributes | User attributes; see User attributes and targeting | No |
clearPreviousAttributes | Replaces previously sent attributes with this set (default false), see below | No |
- Android
- iOS
initialize takes an optional initOptions parameter of type TapInitOptions:
data class TapInitOptions(
val userAttributes: HashMap<String, Any>? = null,
val clearPreviousAttributes: Boolean? = false,
)
See SDK initialization for a full example.
Pass userAttributes and clearPreviousAttributes directly to initialize:
TapResearch.initialize(withAPIToken: apiToken,
userIdentifier: userIdentifier,
userAttributes: ["is_vip": 1],
clearPreviousAttributes: false,
sdkDelegate: self) { (error: NSError?) in
// Handle any error
}
See Send user attributes for Swift and Objective-C examples.
User attributes in initialization
Best practice: If user attributes are known at SDK initialization, pass them through initialization instead of using sendUserAttributes.
Benefit: Faster load times for targeted content.
Clearing previous attributes
Attribute names must be strings and must not begin with tapresearch_, which is reserved for TapResearch. Use string or numeric values for targeting. For booleans, send "true"/"false" or 0/1 instead of native booleans.
Set clearPreviousAttributes to false to merge new values with existing attributes, or true to replace the attributes you previously sent.