Track events
With the justtrack SDK, you can monitor and record user behavior through 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:
- Track predefined events
- Track custom events
- Track events with values
- Check live events in the dashboard
Track predefined events
With our SDK, you can track user behavior using predefined events. 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 track an event you need to pass your event to the publishEvent method of your JustTrackSdk instance:
- Android
- iOS
- Unity
- React Native
- Flutter
kotlin sdk.publishEvent(JtLoginEvent("success", "email"))
swift sdk.publish(event: JtLoginEvent(jtAction: "success", jtMethod: "email"))
csharp JustTrackSDK.PublishEvent(new JustTrack.JtLoginEvent("success", "email"));
ts await JustTrackSdk.publishEvent(new JtLoginEvent('success', 'email'));
dart await JusttrackSdk.track(JtLoginEvent( jtAction: 'success', jtMethod: 'email', ));
Here, JtLoginEvent is a subclass of AppEvent.
It represents a JtLoginEvent
and accepts two predefined dimensions, called jt_action and jt_method.
In this example, you pass the values for those dimensions in the constructor.
You can add more dimensions to an event by calling .addDimension():
- Android
- iOS
- Unity
- React Native
- Flutter
"value")) ```
</TabItem>
<TabItem value="ios">
```swift sdk.publish(event: JtLoginEvent(jtAction: "success", jtMethod: "email") .add(dimension:
"dimension_name", value: "value")) ```
</TabItem>
<TabItem value="unity">
```csharp JustTrackSDK.PublishEvent(new JustTrack.JtLoginEvent("success", "email")
.AddDimension("dimension_name", "value")); ```
</TabItem>
<TabItem value="react-native">
```ts await JustTrackSdk.publishEvent(new JtLoginEvent('success', 'email')
.addDimension('dimension_name', 'value')); ```
</TabItem>
</PlatformTabs>
This sends the event to the justtrack platform where you can visualize and analyze your data.
## Track custom events
Along with predefined events, you can also track custom events.
You define these events yourself, and they're not given any special attention in the platform.
To track a custom event, pass an `AppEvent` object to the `publishEvent` method of your `JustTrackSdk` instance:
<PlatformTabs>
<TabItem value="android">```kotlin sdk.publishEvent(AppEvent("my_event")) ```</TabItem>
<TabItem value="ios">```swift sdk.publish(event: AppEvent("my_event")) ```</TabItem>
<TabItem value="unity">
```csharp JustTrackSDK.PublishEvent(new AppEvent("my_event")); ```
</TabItem>
<TabItem value="react-native">
```ts await JustTrackSdk.publishEvent(new AppEvent('my_event')); ```
</TabItem>
<TabItem value="flutter">```dart await JusttrackSdk.trackEvent('my_event'); ```</TabItem>
</PlatformTabs>
When you create an `AppEvent` object, you can supply it with your own event name, like `my_event`.
<PlatformOnly value={['android', 'react-native', 'unity']}>
You can add dimensions to your custom event with `.addDimension()`:
</PlatformOnly>
<PlatformOnly value="ios">You can add dimensions to your custom event with `.add()`:</PlatformOnly>
<PlatformOnly value="flutter">
You can add dimensions to your custom event by passing a map:
</PlatformOnly>
<PlatformTabs>
<TabItem value="android">
```kotlin
sdk.publishEvent(AppEvent("my_event")
.addDimension("dimension_name", "value"))
sdk.publish(event: AppEvent("my_event")
.add(dimension: "dimension_name", value: "value"))
JustTrackSDK.PublishEvent(new AppEvent("my_event")
.AddDimension("dimension_name", "value"));
await JustTrackSdk.publishEvent(new AppEvent('my_event')
.addDimension('dimension_name', 'value'));
await JusttrackSdk.trackEvent('my_event', {
'dimension_name': 'value',
});
This sends the event to the justtrack platform where you can visualize and analyze your data.
Track events with values
Events can carry numeric values along with dimensions. This is useful for tracking metrics like counts, durations, or monetary amounts.
Track counts
Use count values to track quantities like level completions, items collected, or actions performed:
- Android
- iOS
- Unity
- React Native
- Flutter
.addDimension("difficulty", "hard")) ```
</TabItem>
<TabItem value="ios">
```swift sdk.publish(event: AppEvent("level_complete") .set(count: 15) .add(dimension:
"difficulty", value: "hard")) ```
</TabItem>
<TabItem value="unity">
```csharp JustTrackSDK.PublishEvent(new AppEvent("level_complete") .SetCount(15)
.AddDimension("difficulty", "hard")); ```
</TabItem>
<TabItem value="react-native">
```ts await JustTrackSdk.publishEvent(new AppEvent('level_complete') .setValue(new Value(15,
Unit.Count)) .addDimension('difficulty', 'hard')); ```
</TabItem>
</PlatformTabs>
### Track time
Use time values to track durations like session length, time spent on a screen, or task completion time:
<PlatformTabs>
<TabItem value="android">
```kotlin
// Track time in seconds
sdk.publishEvent(AppEvent("session_ended")
.setSeconds(342.5)
.addDimension("screen", "home"))
// Or in milliseconds
sdk.publishEvent(AppEvent("animation_complete")
.setMilliseconds(1500.0))
// Track time in seconds
sdk.publish(event: AppEvent("session_ended")
.set(seconds: 342.5)
.add(dimension: "screen", value: "home"))
// Or in milliseconds
sdk.publish(event: AppEvent("animation_complete")
.set(milliseconds: 1500))
// Track time in seconds
JustTrackSDK.PublishEvent(new AppEvent("session_ended")
.SetSeconds(342.5)
.AddDimension("screen", "home"));
// Or in milliseconds
JustTrackSDK.PublishEvent(new AppEvent("animation_complete")
.SetMilliseconds(1500));
// Track time in seconds
await JustTrackSdk.publishEvent(new AppEvent('session_ended')
.setValue(new Value(342.5, Unit.Seconds))
.addDimension('screen', 'home'));
// Or in milliseconds
await JustTrackSdk.publishEvent(new AppEvent('animation_complete')
.setValue(new Value(1500, Unit.Milliseconds)));
Track monetary values
Use monetary values to track virtual currency transactions, in-app spending, or other financial metrics:
- Android
- iOS
- Unity
- React Native
- Flutter
sdk.publishEvent(AppEvent("virtual_currency_spent") .setValue(Money(4.99, "USD")).addDimension("item", "premium_pack"))
sdk.publish(event: AppEvent("virtual_currency_spent") .set(money: Money(4.99, "USD")).add(dimension: "item", value: "premium_pack"))
JustTrackSDK.PublishEvent(new AppEvent("virtual_currency_spent") .SetValue(new Money(4.99, "USD")).AddDimension("item", "premium_pack"));
await JustTrackSdk.publishEvent(new AppEvent('virtual_currency_spent') .setValue(new Money(4.99, 'USD')).addDimension('item', 'premium_pack'));
Event restrictions
When you create events, you must adhere to the following requirements:
- Event name
- Can't be empty
- Must be shorter than 256 characters
- Is case-sensitive
- Can only consist of printable ISO 8859-1 characters (U+0020 to U+007E as well as U+00A0 to U+00FF)
- Dimension names
- Must be shorter than 256 characters
- May only consist of:
- Lowercase letters in the Latin alphabet (U+0061 to U+007A)
- Underscores (_) (U+005F)
- Numbers (0-9) (U+0030 to U+0039)
- Dimension values
- Must be shorter than 4096 characters
- Can only consist of printable ISO 8859-1 characters (U+0020 to U+007E as well as U+00A0 to U+00FF)
- Other restrictions
- Maximum of 10 dimensions per event
- Event values must be finite (not NaN or Infinity)
- Currency codes must be 3-letter uppercase ISO 4217 strings (e.g., "USD", "EUR")
If your event doesn't match these criteria, it won't be recorded in the justtrack platform.
Check live events in the dashboard
After you send your first event, you can check the Live Events section on your SDK integration page in the justtrack dashboard. Events appear there about 15 minutes after you track them using the SDK.