Implement user progression events
Implement analytics events for tracking user progression through game levels. These events help monitor player engagement, level completion rates, and gameplay patterns.
Track the following user progression steps:
Add these namespaces to any file that sends progression events:
using Services.Analytics.Events;using Services.Analytics.Models;- LevelContext is class for analytics to track type, number and name of current event. This context values are tracked on application side.
public readonly string LevelType;public readonly int LevelNumber;public readonly string LevelName;
public LevelContext(string levelType, int levelNumber, string levelName){ LevelType = levelType; LevelNumber = levelNumber; LevelName = levelName;}Level start
Section titled “Level start”Player starts the level. Example code:
HyperKit.Analytics.TrackEvent(new LevelStartEvent( new LevelContext("main", levelNumber, $"main_{levelNumber}")));Level complete
Section titled “Level complete”Player completes the level. Example code:
HyperKit.Analytics.TrackEvent(new LevelCompleteEvent( new LevelContext("main", levelNumber, $"main_{levelNumber}")));
// Advanced progression tracking, recommendedHyperKit.Analytics.TrackEvent(new LevelCompleteEvent( new LevelContext("main", levelNumber, $"main_{levelNumber}"), 45, // duration in sec new LevelProgress { moveCount = 45 }));Level fail
Section titled “Level fail”Player fails the level. Example code:
HyperKit.Analytics.TrackEvent(new LevelFailEvent( new LevelContext("main", levelNumber, $"main_{levelNumber}")));
// Advanced progression tracking, recommendedHyperKit.Analytics.TrackEvent(new LevelFailEvent( new LevelContext("main", levelNumber, $"main_{levelNumber}"), 45, // duration in sec new LevelProgress { moveCount = 45 }));Level restart
Section titled “Level restart”Player restarts the level. Example code:
HyperKit.Analytics.TrackEvent(new LevelRestartEvent(levelNumber));Verifying your events
Section titled “Verifying your events”On a normal build you won’t see an SDK log when an event is tracked, even though the event is still sent. HyperKit prints its analytics debug logs only on a debug device (HyperKit.IsDebugDevice()): always in the Unity Editor, and on a real build only when the device is flagged as debug in the backend by its advertising ID. Your own Debug.Log calls aren’t affected, so seeing your logs but not ours is expected. The event is still sent to Firebase and the other destinations where applicable.
To confirm an event fired, use any of:
- Run it in the Unity Editor (Play mode), which always counts as a debug device, so the event log (for
LevelStartEvent:LevelStartEvent Level:LevelType: main, LevelNumber: 1, LevelName: main_1) shows in the Console. - Use Firebase DebugView. Run
adb shell setprop debug.firebase.analytics.app your.package.name, then open Firebase Console and watch DebugView in real time. Turn it off later withadb shell setprop debug.firebase.analytics.app .none. - Make your test device a debug device so the SDK logs show on the build. See the Debug devices section on the Remote configuration page.