Tracking custom events
You can record custom events in Braze to learn more about your app’s usage patterns and segment your users by their actions on the dashboard. This reference article covers how to add and track custom events for your Android or FireOS application.
Before implementation, be sure to review examples of the segmentation options afforded by custom events, custom attributes, and purchase events in our analytics overview, as well as our notes on event naming conventions.
Adding a custom event
1
Braze.getInstance(context).logCustomEvent(YOUR_EVENT_NAME);
1
Braze.getInstance(context).logCustomEvent(YOUR_EVENT_NAME)
Refer to our KDoc for more information.
Adding properties
You can add metadata about custom events by passing a Braze properties object with your custom event.
Properties are defined as key-value pairs. Keys are String
objects, and values can be String
, int
, float
, boolean
, or Date
objects.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Braze.logCustomEvent("YOUR-EVENT-NAME",
new BrazeProperties(new JSONObject()
.put("you", "can")
.put("pass", false)
.put("orNumbers", 42)
.put("orDates", new Date())
.put("or", new JSONArray()
.put("any")
.put("array")
.put("here"))
.put("andEven", new JSONObject()
.put("deeply", new JSONArray()
.put("nested")
.put("json"))
)
));
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Braze.logCustomEvent("YOUR-EVENT-NAME",
BrazeProperties(JSONObject()
.put("you", "can")
.put("pass", false)
.put("orNumbers", 42)
.put("orDates", Date())
.put("or", JSONArray()
.put("any")
.put("array")
.put("here"))
.put("andEven", JSONObject()
.put("deeply", JSONArray()
.put("nested")
.put("json"))
)
))
Reserved keys
The following keys are reserved and cannot be used as custom event properties:
time
event_name
Refer to our KDoc for more information.