setUserAttributes()
A function that sets user attributes for use in paywalls and analytics on the Superwall dashboard.
These attributes should not be used as a source of truth for sensitive information.
Keys beginning with $
are reserved for Superwall internal use and will be ignored. Arrays and dictionaries are not supported as values.
Purpose
Sets custom user attributes that can be used in paywall personalization, audience filters, and analytics on the Superwall dashboard.
Signature
Parameters
Name | Type | Description |
---|---|---|
attributes | [String: Any?] | A dictionary of custom attributes to store for the user. Values can be any JSON encodable value, URLs, or Dates. |
Returns / State
This function returns Void
. If an attribute already exists, its value will be overwritten while other attributes remain unchanged.
Usage
Set multiple user attributes:
Set individual attributes over time:
Remove an attribute by setting it to nil:
Real-world example after user updates profile:
Use these attributes in campaign audience filters on the Superwall dashboard to show targeted paywalls to specific user segments.
How is this guide?