nav_title | article_title | platform | page_order | page_type | description |
---|---|---|---|---|---|
Setting Custom Attributes |
Setting Custom Attributes for Roku |
Roku |
4 |
reference |
This reference article describes methods to assign custom attributes for Roku to users via the Braze SDK. |
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, user attributes, and purchase events in our Best practices. We also recommend familiarizing yourself with our Event naming conventions.
User attributes will be assigned to the currently active user. The following default fields may be set:
FirstName
LastName
Email
Gender
DateOfBirth
Country
Language
HomeCity
PhoneNumber
Implementation Example
This is what setting a first name would look like in code:
m.Braze.setFirstName("User's First Name")
Beyond the default user attributes, Braze also allows you to define custom attributes using several different data types.
{% tabs %} {% tab Boolean %}
m.Braze.setCustomAttribute("boolAttribute", true)
{% endtab %} {% tab Integer %}
m.Braze.setCustomAttribute("intAttribute", 5)
{% endtab %} {% tab Float/Double %}
m.Braze.setCustomAttribute("floatAttribute", 3.5)
Braze treats FLOAT and DOUBLE values exactly the same within our database. {% endtab %} {% tab String %}
m.Braze.setCustomAttribute("stringAttribute", "stringValue")
{% endtab %} {% tab Date %}
dateAttribute = CreateObject("roDateTime")
dateAttribute.fromISO8601String("1992-11-29 00:00:00.000")
m.Braze.setCustomAttribute("dateAttribute", dateAttribute)
{% endtab %} {% tab Array %}
stringArray = createObject("roArray", 3, true)
stringArray.Push("string1")
stringArray.Push("string2")
stringArray.Push("string3")
m.Braze.setCustomAttribute("arrayAttribute", stringArray)
{% endtab %} {% endtabs %}
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.
m.Braze.incrementCustomUserAttribute("intAttribute", 3)
Custom attributes can also be unset using the following method:
m.Braze.unsetCustomAttribute("attributeName")
You can also use our REST API to set user attributes. Refer to the users API documentation for details.
Custom attribute values have a maximum length of 255 characters.
You can set the following email subscription statuses for your users programmatically through the SDK.
Subscription Status | Definition |
---|---|
OptedIn |
Subscribed, and explicitly opted in |
Subscribed |
Subscribed, but not explicitly opted in |
UnSubscribed |
Unsubscribed and/or explicitly opted out |
{: .reset-td-br-1 .reset-td-br-2} |
These types fall under
BrazeConstants().SUBSCRIPTION_STATES
The method for setting email subscription status is setEmailSubscriptionState()
. 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 OptedIn
upon receipt of explicit consent from your user. For more details, visit Managing user subscriptions.
Example usage:
m.Braze.setEmailSubscriptionState(BrazeConstants().SUBSCRIPTION_STATES.OPTED_IN)