Forum Discussion
How to Use the standard user attribute in the Connected audience object filter
from the API side, I followed the document here to create an audience filter and send a message to the audience after this filter.
But the document only mentions using custom attributes:
{
"custom_attribute":
{
"custom_attribute_name": (String) the name of the custom attribute to filter on,
"comparison": (String) one of the allowed comparisons to make against the provided value,
"value": (String, Numeric, Boolean) the value to be compared using the provided comparison
}
}
also can I use standard user attributes, like `country` for example:
{
"attribute_name": "country",
"comparison": "equals",
"value": 'VN'
},
I think Braze does support this, it's just missed from the document side, right?
Thank you sou much
🤦♀️ I think I misinterpreted the docs! Sorry about that, st-haingo The correct approach for filtering based on standard user attributes in the Braze API is indeed to use custom_attribute, and I appreciate your patience.
To clarify, the correct structure for your audience filter when using standard user attributes should look like this:
{ "custom_attribute": { "custom_attribute_name": "country", "comparison": "equals", "value": "VN" } }
So this means that in your API request body for scheduling a message, you should structure it like this:
{ "messages": { "apple_push": { "alert": { "title": "良い一日を!", "body": "I hope 2024 is going to be a better year for this world 12" }, "message_variation_id": "" } }, "campaign_id": "", "schedule": { "time": "2024-11-20T00:50:00+0000" }, "audience": { "AND": [ { "custom_attribute": { "custom_attribute_name": "country", "comparison": "equals", "value": "VN" } } ] } }
If that still doesn't work let me know, or you can always get in touch with support. But I'm gonna tag in some other Braze experts here to validate me (I'm still really new at JSON!) -- DavidO or AllanHeo or Manoj__ any chance you can double check my work? 😅
- eakinseyCommunity Manager
Hi st-haingo! I think I can help here. Yes, you can use standard user attributes in the Connected Audience Object filter in Braze. While the documentation primarily highlights custom attributes, standard user attributes - for example, country - can also be utilized in your audience filters.
LIQUID
{% assign country_filter = { "user_attribute": { "attribute_name": "country", "comparison": "equals", "value": "VN" } } %}
In this Liquid code snippet, we create a variable called country_filter that holds the JSON structure for the audience filter. You can then use this variable in your API call or wherever you need to reference the filter.
JSON
To create a filter using a standard user attribute, you would structure your filter like this:{ "user_attribute": { "attribute_name": "country", "comparison": "equals", "value": "VN" } }
In this example, the user_attribute object is used to specify the standard user attribute you want to filter on, along with the comparison type and the value you're targeting.
Make sure to replace "country" with the actual name of the standard user attribute you want to use, and adjust the comparison and value as needed for your specific use case.
I hope that helps! If so, please take a second to mark this answer as the solution. Thank you! 🙇♀️
- st-haingoActive Member II
I followed the document here to create an audience filter :
https://www.braze.com/docs/api/objects_filters/connected_audience - st-haingoActive Member II
Thank you for your quick reply,
I tried your solution but it is still giving error. This is API detail, could you help me check itAPI: @POST /messages/schedule/create
Request body:
{ "messages": { "apple_push": { "alert": { "title": "良い一日を!", "body": "I hope 2024 is going to be a better year for this world 12" }, "message_variation_id": "" } }, "campaign_id": "", "schedule": { "time": "2024-11-20T009:50:00+0000" }, "audience": { "AND": [ { "user_attribute": { "attribute_name": "country", "comparison": "equals", "value": "VN" } } ] } }
Error message:
{ "message": "user_attribute is not a supported filter type." }
Looks like I made a mistake somewhere, can you point out where I am wrong.
Thank you so much- eakinseyCommunity Manager
🤦♀️ I think I misinterpreted the docs! Sorry about that, st-haingo The correct approach for filtering based on standard user attributes in the Braze API is indeed to use custom_attribute, and I appreciate your patience.
To clarify, the correct structure for your audience filter when using standard user attributes should look like this:
{ "custom_attribute": { "custom_attribute_name": "country", "comparison": "equals", "value": "VN" } }
So this means that in your API request body for scheduling a message, you should structure it like this:
{ "messages": { "apple_push": { "alert": { "title": "良い一日を!", "body": "I hope 2024 is going to be a better year for this world 12" }, "message_variation_id": "" } }, "campaign_id": "", "schedule": { "time": "2024-11-20T00:50:00+0000" }, "audience": { "AND": [ { "custom_attribute": { "custom_attribute_name": "country", "comparison": "equals", "value": "VN" } } ] } }
If that still doesn't work let me know, or you can always get in touch with support. But I'm gonna tag in some other Braze experts here to validate me (I'm still really new at JSON!) -- DavidO or AllanHeo or Manoj__ any chance you can double check my work? 😅
- Manoj__Specialist II
Related Content
- 11 months ago
- 9 months ago
- 5 days ago