Event tracking
The AppTrove Unity SDK enables tracking of user interactions through events, providing insights into how users engage with your app. This section covers how to track built-in events, custom events, revenue events, and pass custom parameters, using event IDs retrieved from the Trackier MMP Panel.
Prerequisites
- AppTrove Unity SDK installed and initialized in your Unity project
- A Trackier MMP account with access to the Trackier Panel
- Unity Editor 2019.4 or later
- Basic knowledge of C# scripting
Retrieve Event ID from Dashboard
To track events, you need the event ID from the Trackier MMP Panel.
Steps to Retrieve Event ID
- Log in to your Trackier Panel.
- Navigate to the Events section in the Dashboard.
- Copy the event ID for the desired built-in or custom event.
Built-in Events
Built-in events are predefined in the Trackier dashboard and can be tracked directly. Examples include TrackierEvent.LOGIN
, TrackierEvent.PURCHASE
, etc.
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
orderId
revenue
currency
param1
toparam10
Steps to Track Built-in Events
- Create a
TrackierEvent
object with the event ID retrieved from the dashboard. - Optionally, set parameters like
param1
,revenue
, orcurrency
. - Call
TrackierUnity.trackierEvent
to track the event.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using com.trackier.sdk;
namespace com.sampleapp
{
public class Script : MonoBehaviour
{
void Start()
{
// Initialize SDK
TrackierConfig trackierConfig = new TrackierConfig("e69b921c-bbe8-xxxx-xxxx-5a9678abffea", "development");
trackierConfig.setAppSecret("6419510xxxxxxxa686cf1", "MzgwYWMwOTQt6xxxxxxxxxxxxxxtZTk3MTMwNTMzMjQ5");
TrackierUnity.initialize(trackierConfig);
// Track Built-in Event
TrackierEvent trackierEvent = new TrackierEvent("sEMWSCTXeu"); // Pass your event ID here
trackierEvent.param1 = "param";
TrackierUnity.trackierEvent(trackierEvent);
}
void Update()
{
}
}
}
Custom Events
Custom events are user-defined in the Trackier dashboard to track app-specific actions tailored to your business logic.
Steps to Track Custom Events
- Create a custom event in the Trackier Panel under the Events section.
- Note the event ID for the custom event.
- Use the same
TrackierEvent
class to track the custom event with its ID.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using com.trackier.sdk;
namespace com.sampleapp
{
public class Script : MonoBehaviour
{
void Start()
{
// Initialize SDK
TrackierConfig trackierConfig = new TrackierConfig("e69b921c-bbe8-xxxx-xxxx-5a9678abffea", "development");
trackierConfig.setAppSecret("6419510xxxxxxxa686cf1", "MzgwYWMwOTQt6xxxxxxxxxxxxxxtZTk3MTMwNTMzMjQ5");
TrackierUnity.initialize(trackierConfig);
// Track Custom Event
TrackierEvent trackierEvent = new TrackierEvent("sEMWSCTXeu"); // Pass your custom event ID here
trackierEvent.param1 = "param";
TrackierUnity.trackierEvent(trackierEvent);
}
void Update()
{
}
}
}
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.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using com.trackier.sdk;
namespace com.sampleapp
{
public class Script : MonoBehaviour
{
public void trackCompleteRegistration()
{
// Create event with COMPLETE_REGISTRATION ID or Custom Event ID
TrackierEvent trackierEvent = new TrackierEvent(TrackierEvent.COMPLETE_REGISTRATION);
// Alternatively: TrackierEvent trackierEvent = new TrackierEvent("w43424"); // Pass your custom Event ID
// Built-in fields for event tracking
trackierEvent.orderId = "REG_001"; // String: Unique registration ID
trackierEvent.currency = "USD"; // String: Currency code
trackierEvent.couponCode = "343434234"; // String: Coupon code used
trackierEvent.discount = 3.1415; // double: Discount applied
trackierEvent.revenue = 34234234.32423f; // float: Revenue (or 0.0 for free signup)
// Custom parameters for structured data
// Data type: String - You can add any string value here
trackierEvent.param1 = "Test1"; // String: Dummy value
trackierEvent.param2 = "Test2"; // String: Dummy value
trackierEvent.param3 = "Test3"; // String: Dummy value
trackierEvent.param4 = "Test4"; // String: Dummy value
trackierEvent.param5 = "Test5"; // String: Dummy value
trackierEvent.param6 = "Test6"; // String: Dummy value
trackierEvent.param7 = "Test7"; // String: Dummy value
trackierEvent.param8 = "Test8"; // String: Dummy value
trackierEvent.param9 = "Test9"; // String: Dummy value
trackierEvent.param10 = "Test10"; // String: Dummy value
// Custom key-value pairs for flexible data (IDictionary<string, object>)
IDictionary<int, object> eventCustomParams = new Dictionary<int, object>();
eventCustomParams.Add(1, "XXXXX"); // customParam1
eventCustomParams.Add(2, "XXXXX"); // customParam2
trackierEvent.ev = eventCustomParams;
// Set user details in Trackier SDK
TrackierUnity.setUserId("USER123"); // String: User ID
TrackierUnity.setUserEmail("user@example.com"); // String: User email
TrackierUnity.setUserName("Jane Doe"); // String: User name
TrackierUnity.setUserPhone("+1234567890"); // String: User phone
TrackierUnity.setDOB("1990-01-01"); // String: Date of birth (YYYY-MM-DD)
TrackierUnity.setGender("Male"); // String: Gender (Male, Female, or Others)
// Additional user details (using eventValues as a workaround)
trackierEvent.eventValues["Plan"] = "FREE_PLAN";
trackierEvent.eventValues["SignupMethod"] = "Email";
trackierEvent.eventValues["AppVersion"] = "1.0.0";
// Send the event to Trackier
TrackierUnity.TrackEvent(trackierEvent);
}
}
}
4. Revenue Events
Revenue events allow you to track in-app revenue, including the amount and currency, to monitor monetization performance.
Steps to Track Revenue Events
- Create a
TrackierEvent
object with the event ID. - Set the
revenue
andcurrency
properties. - Call
TrackierUnity.trackierEvent
to track the revenue event.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using com.trackier.sdk;
namespace com.sampleapp
{
public class Script : MonoBehaviour
{
void Start()
{
// Initialize SDK
TrackierConfig trackierConfig = new TrackierConfig("e69b921c-bbe8-xxxx-xxxx-5a9678abffea", "development");
trackierConfig.setAppSecret("6419510xxxxxxxa686cf1", "MzgwYWMwOTQt6xxxxxxxxxxxxxxtZTk3MTMwNTMzMjQ5");
TrackierUnity.initialize(trackierConfig);
// Track Revenue Event
TrackierEvent trackierEvent = new TrackierEvent("sEMWSCTXeu"); // Pass your event ID here
trackierEvent.param1 = "param";
trackierEvent.revenue = 8.0; // Pass your revenue here
trackierEvent.currency = "INR"; // Pass your currency here
TrackierUnity.trackierEvent(trackierEvent);
}
void Update()
{
}
}
}
5. Custom Parameters
Custom parameters allow you to add additional key-value pairs to events for richer context and analytics.
Steps to Add Custom Parameters
- Create a
Dictionary<int, object>
to store custom parameters. - Add key-value pairs to the dictionary.
- Assign the dictionary to the
ev
property of theTrackierEvent
object. - Track the event using
TrackierUnity.trackierEvent
.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using com.trackier.sdk;
namespace com.sampleapp
{
public class Script : MonoBehaviour
{
void Start()
{
// Initialize SDK
TrackierConfig trackierConfig = new TrackierConfig("e69b921c-bbe8-xxxx-xxxx-5a9678abffea", "development");
trackierConfig.setAppSecret("6419510xxxxxxxa686cf1", "MzgwYWMwOTQt6xxxxxxxxxxxxxxtZTk3MTMwNTMzMjQ5");
TrackierUnity.initialize(trackierConfig);
// Track Event with Custom Parameters
TrackierEvent trackierEvent = new TrackierEvent("sEMWSCTXeu"); // Pass your event ID here
IDictionary<int, object> eventCustomParams = new Dictionary<int, object>();
eventCustomParams.Add(1, "XXXXX"); // customParam1
eventCustomParams.Add(2, "XXXXX"); // customParam2
trackierEvent.ev = eventCustomParams;
TrackierUnity.trackierEvent(trackierEvent);
}
void Update()
{
}
}
}
The input contains a minor inconsistency in the custom parameters code (numberNames.Add
instead of eventCustomParams.Add
). The example above corrects this to use eventCustomParams.Add
.
Best Practices
- Validate Event IDs: Ensure event IDs are correctly copied from the Trackier Panel to avoid tracking errors.
- Use Descriptive Parameters: Set meaningful values for
param1
toparam10
and custom parameters to facilitate analytics. - Test in Development Mode: Use the
"development"
environment during testing to verify event tracking without affecting production data. - Monitor Event Limits: Avoid excessive event tracking to stay within Trackier's usage limits; prioritize key user actions.
- Log Events for Debugging: Add debug logs in your scripts to confirm events are triggered and sent correctly.
- Comply with Privacy Regulations: Ensure event data (e.g., revenue, custom parameters) complies with GDPR, CCPA, and other privacy laws.
Troubleshooting
- Events Not Appearing in Dashboard:
- Verify the event ID matches the one in the Trackier Panel.
- Ensure the SDK is initialized before tracking events.
- Check that the environment (
"development"
or"production"
) matches the dashboard settings.
- Custom Parameters Not Tracked:
- Confirm the dictionary is correctly assigned to
trackierEvent.ev
. - Ensure parameter keys and values are valid and supported by Trackier.
- Confirm the dictionary is correctly assigned to
- Revenue Tracking Issues:
- Verify the
revenue
andcurrency
values are correctly set and use supported currency codes (e.g.,"INR"
,"USD"
).
- Verify the
- General Issues:
- Check the Unity Console for errors related to
TrackierUnity.trackierEvent
.
- Check the Unity Console for errors related to
For further assistance, refer to the Trackier Documentation Portal or contact Trackier support at support@trackier.com.