top of page

Nested Attributes or Arrays of Objects: When to use Which

Jasper Hortillano

Because of their similarities we’ve recently identified that when to use Nested Attributes versus an Array of Objects has some folks a little “Brazed and Confused” (insert giggle here). Both have similar segmentation filters and data presentation behaviors in the Braze GUI, however, as we looked at specific use cases their individuality starts to blossom. Each function has distinct advantages, so let’s take a look at what they are, why you might choose one over the other, and examples of how you may use them in the wild!


blue car at the split of a cross road pointing to either nested attributes or array of objects

Nested Attributes

What?

Nested Attributes are essentially hierarchical data structures where an object contains several related pieces of data under a single key. Each object has its own defined attributes, creating a parent-child relationship in the data.


Why?

  • Simplicity in Representation: If you're working with a clearly defined relationship between parent and child attributes, Nested Attributes provide a structured way to manage that. It's an excellent choice for scenarios where the data complexity is moderate and can be understood within a single hierarchy.


  • Optimized for Specific Data: When dealing with data that's directly related to the user or their specific actions (ex. location, product preferences, or personal identifiers), Nested Attributes provide a streamlined way to access and manage these pieces without having to search through multiple arrays.


  • Efficient Queries: Nested Attributes allow you to easily query data based on the top-level object or its children. For example, if you need to target users who have a specific child attribute, Nested Attributes allow you to do this efficiently.


How?

Let’s say you are running an eCommerce platform, and you want to track your customers’ preferred product categories, such as home goods, electronics, and clothing. Instead of listing these categories as separate objects or in an array, you could leverage a nested structure with Boolean value types to quickly query users based on their preferences for product categories, enabling you to target only those users interested in electronics and clothing without digging through an array of objects.


This segmentation logic is well-defined and straightforward which works is ideal for a Nested Attribute data structure, as displayed below.

screenshot of nested attribute payload

Array of Objects

What?

In Braze, an Array of Objects refers to storing multiple objects, each containing related attributes, within a list. Each object in the array is independent but shares a common format.


Why?

  • Flexibility with Variable Data: Arrays of Objects allow for more flexibility when the data you're working with may vary in size. For example, if you want to track a list of transactions or interactions, an array gives you the freedom to add as many records as needed without changing the overall structure.


  • Tracking Multiple Events or Interactions: When a user engages in multiple interactions or has several related actions (ex. purchases, app interactions, or campaigns), storing them in an array of objects makes it easier to keep track of and query each interaction.


  • Dynamic Data Growth: If the amount of data you’re working with fluctuates—such as event logs, purchase histories, or dynamic content—a flexible array structure is ideal.


How?

In a scenario where you want to track the entire purchase history of a user on an eCommerce platform, an Array of Objects would be the most appropriate structure since the list has the potential for growth. Understanding this, each purchase has several key pieces of data that need to be stored together in the payload object array.


Each transaction is represented as an object and the array holds the user's entire history of purchased items. This setup is highly flexible, allowing for an indefinite number of transactions to be added over time. You can also define segmentation rules based on date, product purchased, or amount spent.


Screenshot of array of objects payload

Key Similarities and Differences

Although we’ve clearly identified how to distinguish when and how to use Nested Attributes versus an Array of Objects, there is one thing very much the same. For a Braze end user, segmentation filter behavior will look exactly the same for both functions. When navigating to the target nested attribute / object defined in your segmentation filters, you access them through the same Nested Custom Attribute menu item.


If you’re still working through the definitions outlined above, we’ve pulled together a quick summary to help you and your users choose the best function for your unique use cases.


Nested Attributes

Array of Objects

Data Relationship

Hierarchical (Parent-child)

List of independent objects

Use Case

Best for representing single sets of related data

Best for tracking multiple events, actions, or objects

Querying

Easier for querying specific related attributes

Better for querying based on individual object data

Data Growth

Limited to predefined attributes; complicated append process

Dynamic and flexible; can grow indefinitely

Example

Preferences, demographics

Purchase histories, event logs

Nested Attributes and Arrays of Objects each have their own perks in Braze and choosing between them really comes down to how complex and changeable your data is. Nested Attributes work great for more structured data that doesn’t shift around too much, while Arrays of Objects give you the flexibility to track multiple events or items that might evolve over time. Picking the right one helps keep your data organized which, ultimately, makes targeting smoother, and boosts personalized engagement in Braze.


If you liked this post and want to learn more about an Array of Objects, check out this article where we dive into the best practice details on working with them. If you just want to get going with Nested Attributes and need help, feel free to reach out here and we'll be more than happy to lend a hand!

bottom of page