Setting custom attributes
The Braze Windows SDK is deprecated as of March 24, 2022.
- March 24, 2022: No new Windows apps can be created in the Braze dashboard.
- September 15, 2022: No new messages can be sent to Windows apps. Existing messages and data collection are unaffected.
- January 15, 2023: Braze will no longer serve messages or collect data from Windows apps.
Braze provides methods for assigning attributes to users. You’ll be able to filter and segment your users according to these attributes on the dashboard.
Before implementation, be sure to review examples of the segmentation options afforded by custom events, custom attributes, and purchase events in our Best practices.
User attributes can be assigned to the current IAppboyUser
. To obtain a reference to the current IAppboyUser
, call Appboy.SharedInstance.AppboyUser
Assigning default user attributes
The following attributes should be defined as properties of the IAppboyUser
:
FirstName
LastName
Email
Gender
DateOfBirth
Country
HomeCity
PhoneNumber
FacebookData
TwitterData
Example Implementation
1
Appboy.SharedInstance.AppboyUser.FirstName = "User's First Name"
Assigning custom user attributes
Beyond the default user attributes, Braze also allows you to define custom attributes using a number of different data types. For more information regarding the segmentation options, and how each of these attributes will affect you, see our Best practices.
Setting custom attribute values
1
bool SetCustomAttribute(STRING_KEY, BOOL_VALUE);
1
bool SetCustomAttribute(STRING_KEY, INT_VALUE);
1
bool SetCustomAttribute(STRING_KEY, DOUBLE_VALUE);
Braze treats FLOAT and DOUBLE values exactly the same within our database.
1
bool SetCustomAttribute(STRING_KEY, "STRING_VALUE");
1
bool SetCustomAttribute(STRING_KEY, LONG_VALUE);
1
bool SetCustomAttribute(STRING_KEY, "DATE_VALUE");
Dates passed to Braze must either be in the [ISO 8601][2] format, e.g
2013-07-16T19:20:30+01:00
or in theyyyy-MM-dd'T'HH:mm:ss:SSSZ
format e.g2016-12-14T13:32:31.601-0800
1
2
3
4
5
6
// Setting a custom attribute with an array value
Appboy.SharedInstance.EventLogger.SetCustomAttributeArray("custom_attribute_array_test", testSetArray);
// Adding to a custom attribute with an array value
Appboy.SharedInstance.EventLogger.AddToCustomAttributeArray("custom_attribute_array_test", testAddString);
// Removing a value from an array type custom attribute
Appboy.SharedInstance.EventLogger.RemoveFromCustomAttributeArray("custom_attribute_array_test", testRemString);
Incrementing/decrementing custom attributes
This code is an example of an incrementing custom attribute. You may increment the value of a custom attribute by any positive or negative integer value.
1
bool IncrementCustomAttribute(STRING_KEY, INCREMENT_INTEGER_VALUE);
Unsetting a custom attribute
Custom attributes can also be unset using the following method:
1
bool UnsetCustomAttribute(STRING_KEY);
Setting a custom attribute via the REST API
You can also use our REST API to set user attributes. Refer to the users API documentation for details.
Custom attribute value limits
Custom attribute values have a maximum length of 255 characters; longer values will be truncated.
Managing notification subscription statuses
To set up a subscription for your users (either email or push), you can set following the subscription statuses as properties of the IAppboyUser
. Subscription statuses in Braze have three different states for both email and push:
Subscription Status | Definition |
---|---|
OptedIn |
Subscribed, and explicitly opted in |
Subscribed |
Subscribed, but not explicitly opted in |
UnSubscribed |
Unsubscribed and/or explicitly opted out |
EmailNotificationSubscriptionType
- Users will be set to
Subscribed
automatically upon receipt of a valid email address, however, we suggest that you establish an explicit opt-in process and set this value toOptedIn
upon receipt of explicit consent from your user.
- Users will be set to
PushNotificationSubscriptionType
- Users will be set to
Subscribed
automatically upon valid push registration, however, we suggest that you establish an explicit opt-in process and set this value toOptedIn
upon receipt of explicit consent from your user.
- Users will be set to
These types fall under
AppboyPlatform.PCL.Models.NotificationSubscriptionType
. Visit Managing user subscriptions for more details.