Setting Custom Attributes

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 vs. Custom Attributes vs Purchase Events in our Best Practices section.

Assigning Standard User Attributes

To assign user attributes, you need to call the appropriate method on the BrazeBinding object. The following is a list of built-in attributes that can be called using this method.

First Name

AppboyBinding.SetUserFirstName("first name");

Last Name

AppboyBinding.SetUserLastName("last name");

User Email

AppboyBinding.SetUserEmail("email@email.com");

It’s still valuable to set email addresses even if you’re not sending emails through Braze. Email makes it easier to search for individual user profiles and troubleshoot issues as they arise.

User Bio

AppboyBinding.SetUserBio() has been deprecated.

Gender

AppboyBinding.SetUserGender(Appboy.Models.Gender.Male or Appboy.Models.Gender.Female);

Birth Date

AppboyBinding.SetUserDateOfBirth("year(int)", "month(int)", "day(int)");

User Country

AppboyBinding.SetUserCountry("country name");

User Home City

AppboyBinding.SetUserHomeCity("city name");

User Email Subscription

AppboyBinding.SetUserEmailNotificationSubscriptionType(AppboyNotificationSubscriptionType.OPTED_IN or AppboyNotificationSubscriptionType.SUBSCRIBED or AppboyNotificationSubscriptionType.UNSUBSCRIBED);

AppboyBinding.SetUserIsSubscribedToEmails() has been deprecated. Please use AppboyBinding.SetUserEmailNotificationSubscriptionType() instead.

User Push Subscription

AppboyBinding.SetUserPushNotificationSubscriptionType(AppboyNotificationSubscriptionType.OPTED_IN or AppboyNotificationSubscriptionType.SUBSCRIBED or AppboyNotificationSubscriptionType.UNSUBSCRIBED);

User Phone Number

AppboyBinding.SetUserPhoneNumber("phone number without hyphens");

User Avatar Image URL

AppboyBinding.SetUserAvatarImageURL("URL");

Assigning Custom User Attributes

Beyond the attributes above, Braze also allows you to define Custom Attributes using a number of different data types: For more information regarding the segmentation options each of these attributes will afford you see our “Best Practices” documentation within this section.

Custom Attribute with a Boolean Value

1
AppboyBinding.SetCustomUserAttribute("custom boolean attribute key", 'boolean value');

Custom Attribute with an Integer Value

1
2
3
4
// Set Integer Attribute
AppboyBinding.SetCustomUserAttribute("custom int attribute key", 'integer value');
// Increment Integer Attribute
AppboyBinding.IncrementCustomUserAttribute("key", increment(int))

Custom Attribute with a Double Value

1
AppboyBinding.SetCustomUserAttribute("custom float attribute key", 'float value');

Braze treats FLOAT and DOUBLE values exactly the same within our database.

Custom Attribute with a String Value

1
AppboyBinding.SetCustomUserAttribute("custom string attribute key", "string custom attribute");

Custom Attribute with a Date Value

1
AppboyBinding.SetCustomUserAttributeToNow("custom date attribute key");
1
AppboyBinding.SetCustomUserAttributeToSecondsFromEpoch("custom date attribute key", 'integer value');

Custom Attribute with an Array Value

1
2
3
4
5
6
// Setting An Array
AppboyBinding.SetCustomUserAttributeArray("key", array(List), sizeOfTheArray(int))
// Adding to an Array
AppboyBinding.AddToCustomUserAttributeArray("key", "Attribute")
// Removing an item from an Array
AppboyBinding.RemoveFromCustomUserAttributeArray("key", "Attribute")

Dates passed to Braze must either be in the ISO 8601 format, e.g 2013-07-16T19:20:30+01:00 or in the yyyy-MM-dd'T'HH:mm:ss.SSSZ format e.g 2016-12-14T13:32:31.601-0800

Unsetting a Custom Attribute

Custom Attributes can also be unset using the following method:

1
AppboyBinding.UnsetCustomUserAttribute("custom attribute key");

Setting a Custom Attribute via the REST API

You can also use our REST API to set user attributes. To do so refer to the user API documentation.

Custom Attribute Value Limits

Custom attribute values have a maximum length of 255 characters; longer values will be truncated.

Setting Up User Subscriptions

To set up a subscription for your users (either email or push), call the functions
AppboyBinding.SetUserEmailNotificationSubscriptionType() or AppboyBinding.SetPushNotificationSubscriptionType(), respectively. Both of these functions take the parameters Appboy.Models.AppboyNotificationSubscriptionType as arguments. This type has three different states:

Subscription Status Definition
OPTED_IN Subscribed, and explicitly opted in
SUBSCRIBED Subscribed, but not explicitly opted in
UNSUBSCRIBED Unsubscribed and/or explicitly opted out

No explicit opt-in is required by Windows to send users push notifications. When a user is registered for push, they are set to SUBSCRIBED rather than OPTED_IN by default. For more information on implementing subscriptions and explicit opt-ins, visit the topic on Braze Academy.

  • 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 to OPTED_IN upon receipt of explicit consent from your user. See Braze Academy for details.
  • 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 to OPTED_IN upon receipt of explicit consent from your user. See Braze Academy for details.

These types fall under Appboy.Models.AppboyNotificationSubscriptionType.

Sample Code

Email Subscription:

1
AppboyBinding.SetUserEmailNotificationSubscriptionType(AppboyNotificationSubscriptionType.OPTED_IN);

Push Notification Subscription:

1
AppboyBinding.SetUserPushNotificationSubscriptionType(AppboyNotificationSubscriptionType.OPTED_IN);
WAS THIS PAGE HELPFUL?