Overview
This guide provides instructions for tracking user interactions in your Flutter application using the AppTrove Flutter SDK's TrackierEvent
object. Event tracking offers insights into user actions, such as logins, purchases, or custom events, enabling better analytics and optimization.
Prerequisites
- A Flutter application with the AppTrove SDK installed and initialized
- Access to the Trackier Panel for configuring custom events
- Flutter 2.0 or later, Dart 2.12 or later
- Basic knowledge of Dart and Flutter development
Event Tracking
Event tracking provides insights into how users interact with your app. The TrackierEvent
object is used to structure and send event information to Trackier servers, triggered by user actions like button clicks. The SDK supports built-in events, custom events, revenue events, and custom parameters.
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
TrackierEvent.LOGIN
TrackierEvent.REGISTER
TrackierEvent.LOGOUT
TrackierEvent.PURCHASE
TrackierEvent.CHECKOUT_STARTED
TrackierEvent.CHECKOUT_COMPLETED
TrackierEvent.ADD_TO_WISHLIST
TrackierEvent.CONTENT_VIEW
TrackierEvent.VIEW_CART
TrackierEvent.REMOVE_FROM_CART
TrackierEvent.SEARCH
TrackierEvent.PRODUCT_VIEW
TrackierEvent.UPDATE
TrackierEvent.INVITE
TrackierEvent.SHARE
TrackierEvent.START_TRIAL
TrackierEvent.SUBSCRIBE
TrackierEvent.COMPLETE_REGISTER
TrackierEvent.ACHIEVEMENT_UNLOCK
TrackierEvent.TUTORIAL_COMPLETE
TrackierEvent.APP_OPEN
TrackierEvent.TRAVEL_BOOKING
TrackierEvent.PRODUCT_SEARCH
TrackierEvent.REGISTRATION
TrackierEvent.ADD_TO_CART
TrackierEvent.LEVEL_ACHIEVED
Available 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
Usage
Create a TrackierEvent
instance with the event ID and trigger it on a user action, such as a button click. Below is an example for tracking a LOGIN
event.
/*
* Event Tracking
* <------------->
* The below code is the example to pass an event to the AppTrove SDK.
* This event requires only 1 Parameter which is the Event ID.
* Below are the example of built-in events function calling
* The arguments - "TrackierEvent.LOGIN" passed in the Trackier event class is Events id
*/
void _eventsTracking() {
TrackierEvent trackierEvent = 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 */
trackierEvent.param1 = "param1";
trackierEvent.param2 = "param2";
trackierEvent.param3 = "param3";
trackierEvent.param4 = "param4";
trackierEvent.param5 = "param5";
trackierEvent.setEventValue("ev1", "eventValue1");
trackierEvent.setEventValue("ev2", 1);
Trackierfluttersdk.trackEvent(trackierEvent);
}
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.
/*
* Event Tracking
* <------------->
* The below code is the example to pass an event to the AppTrove SDK.
* This event requires only 1 Parameter which is the Event ID.
* Below are the example of customs events function calling for `AppOpen` event name.
* The arguments - "sEMWSCTXeu" passed in the Trackier event class is Events id
*/
void _eventsTracking() {
TrackierEvent trackierEvent = 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 */
trackierEvent.param1 = "param1";
trackierEvent.param2 = "param2";
trackierEvent.param3 = "param3";
trackierEvent.param4 = "param4";
trackierEvent.param5 = "param5";
trackierEvent.setEventValue("ev1", "eventValue1");
trackierEvent.setEventValue("ev2", 1);
Trackierfluttersdk.trackEvent(trackierEvent);
}
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.
void trackCompleteRegistration() {
// Create event with COMPLETE_REGISTRATION ID (String) or Custom Event ID
TrackierEvent event = TrackierEvent(TrackierEvent.COMPLETE_REGISTRATION);
// Alternatively: TrackierEvent event = TrackierEvent("w43424"); // Pass your Event ID
// Built-in fields for event tracking
event.orderId = "REG_001"; // String: Unique registration ID
event.couponCode = ""; // String: No coupon used (empty for free plan)
event.discount = 0.0; // double: No discount applied
event.revenue = 0.0; // double: No revenue (free signup)
event.currency = "USD"; // String: Currency code
// 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 (Map<String, Object>)
event.setEventValue("signup_time", 1631234567890); // int: Timestamp
event.setEventValue("device", "Flutter"); // String: Device type
// Set user details in Trackier SDK
Trackierfluttersdk.setUserId("USER123"); // String: User ID
Trackierfluttersdk.setUserEmail("user@example.com"); // String: User email
Trackierfluttersdk.setUserName("Jane Doe"); // String: User name
Trackierfluttersdk.setUserPhone("+1234567890"); // String: User phone
Trackierfluttersdk.setDOB("1990-01-01"); // String: Date of birth (YYYY-MM-DD)
Trackierfluttersdk.setGender(Gender.Male); // Gender: Male, Female, or Others
Trackierfluttersdk.setIMEI("123456789012345", "987654321098765"); // String, String: Device IMEI
Trackierfluttersdk.setMacAddress("00:1A:2B:3C:4D:5E"); // String: Device MAC address
//Passing the custom params in events be like below example
var eventCustomParams = Map<String, Object>();
eventCustomParams={"name":"abcd"};
eventCustomParams={"age":"28"};
event.evMap=eventCustomParams;
// Additional user details (Map)
Map<String, Object> userDetails = {
"Plan": "FREE_PLAN",
"SignupMethod": "Email",
"AppVersion": "1.0.0",
};
Trackierfluttersdk.setUserAdditonalDetail(userDetails);
// Send the event to Apptrove
Trackierfluttersdk.trackEvent(event);
}
4. Revenue Events
Revenue events track in-app revenue, including the amount, currency, and order ID, to monitor app monetization. Use these for actions like purchases, subscription activations, or in-app purchase completions.
Usage
Create a TrackierEvent
instance, set the revenue
, currency
, and other relevant fields, and trigger the event.
void _revenueEventsTracking() {
// Below are the example of revenue events function calling
// The arguments - "TrackierEvent.LOGIN" passed in the event class is Events id
TrackierEvent trackierEvent = TrackierEvent(TrackierEvent.LOGIN);
// Passing the revenue events be like below example
trackierEvent.revenue = 10.0; // Pass your generated revenue here
trackierEvent.currency = "INR"; // Pass your currency here
trackierEvent.orderId = "orderID";
trackierEvent.param1 = "param1";
trackierEvent.param2 = "param2";
trackierEvent.setEventValue("ev1", "eventValue1");
trackierEvent.setEventValue("ev2", 1);
Trackierfluttersdk.trackEvent(trackierEvent);
}
5. Custom Parameters
Add custom key-value pairs to events for additional context, such as user details or event-specific metadata.
Usage
Create a TrackierEvent
instance, set custom parameters using a Map
, and assign it to evMap
before tracking.
void customParamTracking() {
// Below are the example of revenue events function calling
// The arguments - "TrackierEvent.LOGIN" passed in the event class is Events id
TrackierEvent trackierEvent = TrackierEvent(TrackierEvent.LOGIN);
// Passing the custom params in events be like below example
var eventCustomParams = Map<String, Object>();
eventCustomParams["name"] = "abcd";
eventCustomParams["age"] = "28";
trackierEvent.evMap = eventCustomParams;
Trackierfluttersdk.trackEvent(trackierEvent);
}
Best Practices
- Use Built-in Events: Leverage built-in events for standard interactions to simplify integration.
- Define Custom Events: Create custom events in the Trackier dashboard for app-specific actions.
- Include Relevant Parameters: Set
revenue
,currency
, andorderId
for revenue events to ensure accurate monetization tracking. - Test in Development Mode: Use
"development"
or"testing"
environments to validate events before switching to"production"
. - Use Meaningful Parameter Names: Choose descriptive names for custom parameters to improve reporting clarity.
- Trigger Events Asynchronously: Ensure events do not block the main thread to maintain app performance.
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
,currency
, andorderId
fields are set correctly. - Custom Parameters Not Recorded: Check that the
evMap
is properly assigned before tracking the event.
For further assistance, refer to the Trackier Documentation Portal or contact Trackier support at support@trackier.com.