Overview
This guide provides instructions for tracking user interactions in your Android application using the AppTrove SDK's TrackierEvent
object. Event tracking offers insights into how users engage with your app, supporting both built-in and custom events.
Prerequisites
- Access to the Trackier Panel for configuring custom events
- Basic knowledge of Android development (Java or Kotlin)
Event Tracking
The AppTrove SDK provides a TrackierEvent
object to structure and send event information from your app to Trackier servers. Events can be triggered by user actions, such as button clicks, and support both built-in and custom configurations.
1. Built-in Events
Built-in events are predefined constants available on the Trackier dashboard. You can implement these events directly in your app to track common user interactions.
Supported Built-in Events
LOGIN
REGISTER
LOGOUT
PURCHASE
CHECKOUT_STARTED
CHECKOUT_COMPLETED
ADD_TO_WISHLIST
CONTENT_VIEW
VIEW_CART
REMOVE_FROM_CART
SEARCH
PRODUCT_VIEW
UPDATE
INVITE
SHARE
START_TRIAL
SUBSCRIBE
COMPLETE_REGISTER
ACHIEVEMENT_UNLOCK
TUTORIAL_COMPLETE
APP_OPEN
TRAVEL_BOOKING
PRODUCT_SEARCH
REGISTRATION
ADD_TO_CART
LEVEL_ACHIEVED
In-built Parameters
You can include additional data with events using the following parameters:
orderId
revenue
currency
param1
,param2
,param3
,param4
,param5
,param6
,param7
,param8
,param9
,param10
The argument passed to the TrackierEvent
class is the event ID (e.g., TrackierEvent.LOGIN
for built-in events).
Usage
Create a TrackierEvent
instance and trigger it on a user action, such as a button click. Below are examples for tracking a LOGIN
event.
Track Event Example
- Java
- Kotlin
private void eventsTracking(){
// Below are the example of built-in events function calling
// The arguments - "TrackierEvent.LOGIN" passed in the Trackier event class is Events id
TrackierEvent event = new TrackierEvent(TrackierEvent.LOGIN);
/* Below are the function for the adding the extra data,
You can add the extra data like login details of user or anything you need.
We have 10 params to add data, Below 5 are mentioned */
event.param1 = "Param 1";
event.param2 = "Param 2";
event.param3 = "Param 3";
event.param4 = "Param 4";
event.param5 = "Param 5";
TrackierSDK.trackEvent(event);
Log.d("TAG", "onClick: event_track ");
}
fun eventsTracking(){
// Below are the example of built-in events function calling
// The arguments - "TrackierEvent.LOGIN" passed in the Trackier event class is Events id.
val event = TrackierEvent(TrackierEvent.LOGIN)
/* Below are the function for the adding the extra data,
You can add the extra data like login details of user or anything you need.
We have 10 params to add data, Below 5 are mentioned */
event.param1 = "Param 1"
event.param2 = "Param 2"
event.param3 = "Param 3"
event.param4 = "Param 4"
event.param5 = "Param 5"
TrackierSDK.trackEvent(event)
Log.d("TAG", "onClick: event_track ")
}
2. Custom Events
Custom events are defined in the Trackier dashboard and identified by unique event IDs. Use these to track app-specific interactions not covered by built-in events.
Usage
Create a TrackierEvent
instance with the custom event ID from the Trackier dashboard and trigger it as needed.
- Java
- Kotlin
private void customEventsTracking(){
// Below are the example of customs events function calling
// The arguments - "sEMWSCTXeu" passed in the event class is Events id
TrackierEvent event = new TrackierEvent("sEMWSCTXeu");
/* Below are the function for the adding the extra data,
You can add the extra data like login details of user or anything you need.
We have 10 params to add data, Below 5 are mentioned */
event.param1 = "Param 1";
event.param2 = "Param 2";
event.param3 = "Param 3";
event.param4 = "Param 4";
event.param5 = "Param 5";
TrackierSDK.trackEvent(event);
Log.d("TAG", "onClick: event_track ");
}
fun customEventsTrcking() {
// Below are the example of customs events function calling
// The arguments - "sEMWSCTXeu" passed in the event class is Events id
val event = TrackierEvent("sEMWSCTXeu")
/* Below are the function for the adding the extra data,
You can add the extra data like login details of user or anything you need.
We have 10 params to add data, Below 5 are mentioned */
event.param1 = "Praram Name";
event.param2 = "Param 2";
event.param3 = "Param 3";
event.param4 = "Param 4";
event.param5 = "Param 5";
TrackierSDK.trackEvent(event)
Log.d("TAG", "onClick: event_curr_track ")
}
3. Complete Event Tracking Example
This comprehensive example demonstrates how to track a COMPLETE_REGISTRATION
event with all available parameters, user data, and custom attributes.
- Java
- Kotlin
public static void trackCompleteRegistration() {
// Create event with COMPLETE_REGISTRATION ID (String) or Custom Event ID
TrackierEvent event = new TrackierEvent(TrackierEvent.COMPLETE_REGISTRATION);
// Alternatively: TrackierEvent event = new TrackierEvent("w43424"); // Pass your Event ID
// Built-in fields for event tracking
event.orderId = "REG_001"; // String: Unique registration ID
event.productId = "FREE_PLAN"; // String: Plan or product ID
event.currency = "USD"; // String: Currency code
event.couponCode = "343434234"; // String: Coupon code used
event.discount = 3.1415f; // Float: Discount applied (or null)
event.revenue = 34234234.32423; // Double: Revenue (or null for free signup)
// Custom parameters for structured data
// Data type: String - You can add any string value here
event.param1 = "Test1"; // String: Dummy value
event.param2 = "Test2"; // String: Dummy value
event.param3 = "Test3"; // String: Dummy value
event.param4 = "Test4"; // String: Dummy value
event.param5 = "Test5"; // String: Dummy value
event.param6 = "Test6"; // String: Dummy value
event.param7 = "Test7"; // String: Dummy value
event.param8 = "Test8"; // String: Dummy value
event.param9 = "Test9"; // String: Dummy value
event.param10 = "Test10"; // String: Dummy value
// Custom key-value pairs for flexible data (HashMap<String, Object>)
HashMap<String, Object> customParams = new HashMap<>();
customParams.put("signup_time", 1631234567890L); // Long: Timestamp
customParams.put("device", "Android"); // String: Device type
event.ev = customParams;
// Set user details in Trackier SDK
TrackierSDK.setUserId("USER123"); // String: User ID
TrackierSDK.setUserEmail("user@example.com"); // String: User email
TrackierSDK.setUserName("Jane Doe"); // String: User name
TrackierSDK.setUserPhone("+1234567890"); // String: User phone
TrackierSDK.setDOB("1990-01-01"); // String: Date of birth (YYYY-MM-DD)
TrackierSDK.setGender(TrackierSDK.Gender.Male); // Gender: Male, Female, or Others
TrackierSDK.setIMEI("123456789012345", "987654321098765"); // String, String: Device IMEI
TrackierSDK.setMacAddress("00:1A:2B:3C:4D:5E"); // String: Device MAC address
// Additional user details (HashMap<String, Object>)
HashMap<String, Object> userDetails = new HashMap<>();
userDetails.put("Plan", "FREE_PLAN");
userDetails.put("SignupMethod", "Email");
TrackierSDK.setUserAdditionalDetails(userDetails);
// Send the event to Apptrove
TrackierSDK.trackEvent(event);
}
fun trackCompleteRegistration() {
// Create event with COMPLETE_REGISTRATION ID (String) or Custom Event ID
val event = TrackierEvent(TrackierEvent.COMPLETE_REGISTRATION) // Or TrackierEvent("w43424")
// Built-in fields for event tracking
event.orderId = "REG_001" // String?: Unique registration ID
event.productId = "FREE_PLAN" // String?: Plan or product ID
event.currency = "USD" // String?: Currency code
event.couponCode = "343434234" // String?: No coupon used
event.discount = 3.1415f // Float?: No discount applied or null
event.revenue = 34234234.32423 // Double?: No revenue (free signup) or null
// Custom parameters for structured data
// Datatype: String? → You can add any string value here
event.param1 = "Test1" // String?: Dummy value
event.param2 = "Test2" // String?: Dummy value
event.param3 = "Test3" // String?: Dummy value
event.param4 = "Test4" // String?: Dummy value
event.param5 = "Test5" // String?: Dummy value
event.param6 = "Test6" // String?: Dummy value
event.param7 = "Test7" // String?: Dummy value
event.param8 = "Test8" // String?: Dummy value
event.param9 = "Test9" // String?: Dummy value
event.param10 = "Test10" // String?: Dummy value
// Custom key-value pairs for flexible data (MutableMap<String, Any>)
val customParams = mutableMapOf<String, Any>()
customParams["signup_time"] = 1631234567890L // Long: Timestamp
customParams["device"] = "Android" // String: Device type
event.ev = customParams
// Set user details in Trackier SDK
TrackierSDK.setUserId("USER123") // String: User ID
TrackierSDK.setUserEmail("user@example.com") // String: User email
TrackierSDK.setUserName("Jane Doe") // String: User name
TrackierSDK.setUserPhone("+1234567890") // String: User phone
TrackierSDK.setDOB("1990-01-01") // String: Date of birth (YYYY-MM-DD)
TrackierSDK.setGender(TrackierSDK.Gender.Male) // Gender: Male or Female or Others
TrackierSDK.setIMEI("123456789012345", "987654321098765") // String, String: Device IMEI
TrackierSDK.setMacAddress("00:1A:2B:3C:4D:5E") // String: Device MAC address
// Additional user details (MutableMap<String, Any>)
val userDetails: MutableMap<String, Any> = mutableMapOf()
userDetails["Plan"] = "FREE_PLAN"
userDetails["SignupMethod"] = "Email"
TrackierSDK.setUserAdditionalDetails(userDetails)
// Send the event to Apptrove
TrackierSDK.trackEvent(event)
}
4. Revenue Events
Revenue events track in-app revenue, including the amount and currency, to monitor app monetization.
Usage
Create a TrackierEvent
instance, set the revenue
and currency
fields, and trigger the event.
- Java
- Kotlin
private void revenueEventsTracking(){
// Below are the example of inbuilt events function calling
// The arguments - "TrackierEvent.LOGIN" passed in the event class is Events id
TrackierEvent event = new TrackierEvent("sEMWSCTXeu");
// Passing the revenue events be like below example
event.revenue = 2.5; // Pass your generated revenue here.
event.currency = "USD"; // Pass your currency here.
TrackierSDK.trackEvent(event);
Log.d("TAG", "onClick: event_track ");
}
fun revenueEventsTrcking() {
// Below are the example of customs events function calling
// The arguments - "sEMWSCTXeu" passed in the event class is Events id
val event = TrackierEvent("sEMWSCTXeu")
// Passing the revenue events be like below example
event.revenue = 2.5 // Pass your generateed revenue here.
event.currency = "USD" // Pass your currency here.
TrackierSDK.trackEvent(event)
Log.d("TAG", "onClick: event_curr_track ")
}
5. Custom Parameters in Events
You can pass additional custom parameters using a mutable map, which is assigned to the ev
field of the TrackierEvent
object.
Usage
Create a mutable map, add custom parameters, and assign it to the event's ev
field before tracking.
- Java
- Kotlin
private void customEventsTracking(){
// Below are the example of inbuilt events function calling
// The arguments - "TrackierEvent.LOGIN" passed in the event class is Events id
TrackierEvent event = new TrackierEvent("sEMWSCTXeu");
// Passing the extra data through customs params
HashMap<String,Object> eventCustomParams= new HashMap<>();
eventCustomParams.put("customParam1","xxxxxx");
eventCustomParams.put("customParam2","xxxxxx");
event.ev = eventCustomParams; // Pass the reference to the ev
TrackierSDK.trackEvent(event);
Log.d("TAG", "onClick: event_track ");
}
private fun customEventsTracking() {
// Below is an example of a custom event function call
// The argument "sEMWSCTXeu" passed in the event class is the Event ID
val event = TrackierEvent("sEMWSCTXeu")
// Passing extra data through custom params
val eventCustomParams = mutableMapOf<String, Any>()
eventCustomParams["customParam1"] = "xxxxxx"
eventCustomParams["customParam2"] = "xxxxxx"
event.ev = eventCustomParams // Pass the reference to ev
TrackierSDK.trackEvent(event)
Log.d("TAG", "onClick: event_track")
}
Best Practices
- Use built-in events for standard interactions to simplify integration.
- Define custom events in the Trackier dashboard for app-specific actions.
- Include relevant parameters (e.g.,
revenue
,currency
) for revenue events to ensure accurate monetization tracking. - Test events in
"testing"
mode before switching to"production"
. - Use meaningful parameter names for custom parameters to improve reporting clarity.
- Set user data before tracking events to ensure proper attribution.
- Use consistent data types and formats across all parameters.
Troubleshooting
- Events Not Tracking: Verify the SDK is initialized and the correct event ID is used.
- Invalid Parameters: Ensure parameter names match those defined in the Trackier dashboard.
- Revenue Issues: Confirm the
revenue
andcurrency
fields are set correctly. - User Data Issues: Ensure user data is set before tracking events.