Analytics
The Analytics module provides functionality for tracking game events and user behavior metrics.
Overview
The Analytics module allows you to:
- Track custom game events with names and values
- Monitor user behavior patterns
- Analyze performance metrics
- Generate insights in the Pixidus Dashboard
View your analytics data in the Pixidus Dashboard to gain insights into player behavior and game performance.
Methods
LogEvent
Log a custom event with a name and value. Use this to track any game action or milestone.
Unity
// Log a simple event
PixidusSDK.Analytics.LogEvent("eventName", "eventValue");Parameters:
eventName(string): The name/category of the eventeventValue(string): The value or data associated with the event
Common Event Examples
Level Progression
Unity
// Track level start
PixidusSDK.Analytics.LogEvent("level_start", "level_5");
// Track level completion
PixidusSDK.Analytics.LogEvent("level_complete", "level_5");
// Track level failed
PixidusSDK.Analytics.LogEvent("level_failed", "level_5");Player Actions
Unity
// Track item purchase
PixidusSDK.Analytics.LogEvent("item_purchased", "sword_legendary");
// Track power-up usage
PixidusSDK.Analytics.LogEvent("powerup_used", "speed_boost");
// Track achievement unlocked
PixidusSDK.Analytics.LogEvent("achievement", "first_boss_defeated");Game Session
Unity
// Track game session start
PixidusSDK.Analytics.LogEvent("session_start", System.DateTime.Now.ToString());
// Track tutorial completion
PixidusSDK.Analytics.LogEvent("tutorial", "completed");
// Track game mode selected
PixidusSDK.Analytics.LogEvent("game_mode", "multiplayer");Example Usage
Here’s a complete example of implementing analytics tracking in your game:
Unity
using UnityEngine;
using Pixidus;
public class AnalyticsManager : MonoBehaviour
{
private float sessionStartTime;
private void Start()
{
sessionStartTime = Time.time;
LogSessionStart();
}
private void OnApplicationQuit()
{
LogSessionEnd();
}
public void LogSessionStart()
{
PixidusSDK.Analytics.LogEvent("session_start", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
}
public void LogSessionEnd()
{
float sessionDuration = Time.time - sessionStartTime;
PixidusSDK.Analytics.LogEvent("session_duration", sessionDuration.ToString("F0"));
}
public void LogLevelStart(int levelNumber)
{
PixidusSDK.Analytics.LogEvent("level_start", $"level_{levelNumber}");
}
public void LogLevelComplete(int levelNumber, int score, float timeSpent)
{
PixidusSDK.Analytics.LogEvent("level_complete", $"level_{levelNumber}");
PixidusSDK.Analytics.LogEvent("level_score", $"level_{levelNumber}:{score}");
PixidusSDK.Analytics.LogEvent("level_time", $"level_{levelNumber}:{timeSpent:F1}s");
}
public void LogLevelFailed(int levelNumber, string reason)
{
PixidusSDK.Analytics.LogEvent("level_failed", $"level_{levelNumber}");
PixidusSDK.Analytics.LogEvent("fail_reason", reason);
}
public void LogPurchase(string itemId, int price)
{
PixidusSDK.Analytics.LogEvent("purchase", $"{itemId}:{price}");
}
public void LogAchievement(string achievementId)
{
PixidusSDK.Analytics.LogEvent("achievement_unlocked", achievementId);
}
public void LogButtonClick(string buttonName)
{
PixidusSDK.Analytics.LogEvent("button_click", buttonName);
}
public void LogError(string errorMessage)
{
PixidusSDK.Analytics.LogEvent("error", errorMessage);
}
}Best Practices
-
Use consistent naming conventions - Use snake_case for event names (e.g.,
level_complete,item_purchased) -
Keep event names descriptive - Make it clear what the event represents
-
Include relevant context - Add useful data in the event value (level number, item ID, etc.)
-
Don’t over-track - Focus on meaningful events that provide actionable insights
-
Track funnel events - Log events that help you understand player progression and drop-off points
Support
Need help? Our support team is here for you: