Send app events
With the justtrack SDK, you can monitor and record user behaviors as events. These allow you to track how your users are using your app. For each event, you can also specify dimensions which you can later use to filter, sort, and group your events in the dashboard.
In this guide, you'll learn to:
- Send predefined events
- Send custom events
- Await the results of publishing events
Publish a predefined app event
With our SDK, you can send predefined events to your justtrack account. These events are defined by justtrack and are given special attention in the platform. For example, some metrics are calculated for you if you send data in certain predefined events.
You can find our list of predefined events here.
To send a predefined event, you first create an event object:
- Java
- Kotlin
AppEvent event = new JtLoginEvent("success", "facebook");
val event = JtLoginEvent("success", "facebook")
Here, JtLoginEvent
is a subclass of AppEvent
.
It represents a JtLoginEvent
and accepts two predefined dimension, called jt_action
and jt_method
.
In this example, you pass the value for that dimension in the constructor.
You can add more dimensions with .addDimension()
:
- Java
- Kotlin
AppEvent event = new JtLoginEvent("success", "facebook")
.addDimension("dimension_name", "value");
val event = JtLoginEvent("success", "facebook")
.addDimension("dimension_name", "value")
You can pass all predefined dimensions that belong to a predefined event to the constructor.
For all other dimensions, you must use .addDimension()
.
When you've created and configured an event object, call .publishEvent()
:
- Java
- Kotlin
sdk.publishEvent(event);
sdk.publishEvent(event)
This sends the event to the justtrack platform where you can visualize and analyze your data.
Publish an app event
Along with predefined events, you can also send custom events to your justtrack account. You define these events yourself and they're not given any special attention in the platform.
To send an app event, you first create an event object:
- Java
- Kotlin
AppEvent event = new AppEvent("my_event");
val event = AppEvent("my_event")
Here, you create a custom AppEvent
object and supply an event name, my_event
.
You can add dimensions to your custom event with .addDimension()
:
- Java
- Kotlin
AppEvent event = new AppEvent("my_event")
.addDimension("dimension_name", "value");
val event = AppEvent("my_event")
.addDimension("dimension_name", "value")
When you've created and configured an event object, call .publishEvent()
:
- Java
- Kotlin
sdk.publishEvent(event);
sdk.publishEvent(event)
This sends the event to the justtrack platform where you can visualize and analyze your data.
Conclusion
Now that you know how to send events to your justtrack account,
you can review further details of the AppEvent
class in our
AppEvent API documentation.