Implementing Analytics
How to trigger analytics events in game code, and which obligatory (and optional) events to fire through Pley SDK AnalyticsKit.
Full overview of analytics on Pley.
When launching a game through Pley, a set of analytics events is required for your game to function. This article is a how-to to implement fire those events correctly, as well as optional tracking.
Through the Pley SDK in the game code, you can trigger gameplay and player behavior-related events.
- Initialize Pley AnalyticsKit after the game and player data has been loaded by calling
Pley.AnalyticsKit.Initialize(config);
. - Use
Pley.AnalyticsKit.EVENT
method to trigger analytics events in the game code, providing the correct data to the method. - Fire the mandatory events through the Pley SDK's analytics kit (example below).
- Fire all optional gameplay events relevant to your game to the game code.
- Optional: Catch the events through the game site which has the Web Playable or Pley Web SDK embedded on it, and send them to the analytics service of your choice. (Read more here)
Example:
//Initialize analyticsKit with player properties
Pley.AnalyticsKit.Initialize(config);
//Example of how to fire an event
PleyResult result = Pley.AnalyticsKit.GameLoaded();
if (result != PleyResult.OK)
{
Debug.LogError("Failed to fire Pley analytics event game_loaded.");
}
/////////////////////////////////////////////////////////////////////////
//Example of how to fire an event with parameters
int playerLevel = 3;
PleyResult result = Pley.AnalyticsKit.LevelAdvanced(playerLevel);
if (result != PleyResult.OK)
{
Debug.LogError("Failed to fire Pley analytics event level_advanced");
}
Must-have Events
These events must be triggered in the correct place for your game to function.
Event | Description | Properties |
---|---|---|
game_loaded | AnalyticsKit.GameLoaded(); should be called whenever the game finishes the initial loading, and the game is interactable for the player. Call this method whenever the loading screen is complete. | |
game_user_interacted | AnalyticsKit.UserInteracted(); should be called whenever the player takes their first meaningful action in the game, such as clicking a button or taking their first game action. | |
game_user_engaged | AnalyticsKit.UserEngaged(); should be called whenever the user is considered engaged. It is recommended to fire this event after about 5 minutes of uninterrupted gameplay. | |
gameplay_analytics_initialized | Analyticskit.Initialize(AnalyticsKit.Config); should be called on startup, after the player data has been loaded. (C# API Reference ) | username , level , application_version , custom_user_id , currencies[] |
gameplay_tutorial_started | Analyticskit.TutorialStarted(); should be called whenever the first tutorial instructions are displayed on the screen. Used to track the new user journey. (C# API Ref ) | |
gameplay_tutorial_advanced | Analyticskit.TutorialAdvanced(String); should be called when a tutorial step is completed. Used to track the new user journey (C# API Ref ). | tutorial_step |
gameplay_tutorial_completed | Analyticskit.TutorialCompleted(); When the player completes the tutorial. (C# API Ref ). | - |
Automatic Events
These events are available but require no implementation.
Event | Description | Properties |
---|---|---|
game_load_started | Triggers as soon as the loading begins (before the game code executes). This occurs after the "start"-button is clicked or the game automatically starts. | - |
playable_loaded | Triggers when the Web Playable completes its initialization. When playable_loaded fires, the game takes over and continues loading. Web Playable loads the necessary assets (cached or downloaded) for the game and game engine to launch. | - |
purchase_started | Tracks purchases. | |
purchase_completed | Tracks purchases. | |
game_crashed | Records crash data. All crashes can be found in the Game Manager Crash Log. |
Optional Events
These events are optional.
Event | Description | Properties |
---|---|---|
gameplay_tutorial_skipped | When the player skips the tutorial. | - |
gameplay_premium_spent | When the player spends premium currency. | name , amount , source , new_balance |
gameplay_premium_gained | When the player gains premium currency. | name , amount , source , new_balance |
gameplay_resource_spent | When the player spends game currency. | name , amount , source , new_balance |
gameplay_resource_gained | When the player gains game currency. | name , amount , source , new_balance |
gameplay_offer_shown | When the player is shown an offer, deal, liveOps, or promotion. | offer |
Custom Event | Set any game-specific custom event you need, and deliver it to your analytics services. | name ,parameters[] |
Updated 5 days ago