Skip to Content
ModulesAnalytics

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.

// Log a simple event PixidusSDK.Analytics.LogEvent("eventName", "eventValue");

Parameters:

  • eventName (string): The name/category of the event
  • eventValue (string): The value or data associated with the event

Common Event Examples

Level Progression

// 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

// 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

// 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:

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

  1. Use consistent naming conventions - Use snake_case for event names (e.g., level_complete, item_purchased)

  2. Keep event names descriptive - Make it clear what the event represents

  3. Include relevant context - Add useful data in the event value (level number, item ID, etc.)

  4. Don’t over-track - Focus on meaningful events that provide actionable insights

  5. 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:

Last updated on