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.

  1. Initialize Pley AnalyticsKit after the game and player data has been loaded by calling Pley.AnalyticsKit.Initialize(config);.
  2. Use Pley.AnalyticsKit.EVENT method to trigger analytics events in the game code, providing the correct data to the method.
  3. Fire the mandatory events through the Pley SDK's analytics kit (example below).
  4. Fire all optional gameplay events relevant to your game to the game code.
  5. 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.

EventDescriptionProperties
game_loadedAnalyticsKit.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_interactedAnalyticsKit.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_engagedAnalyticsKit.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_initializedAnalyticskit.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_startedAnalyticskit.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_advancedAnalyticskit.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_completedAnalyticskit.TutorialCompleted(); When the player completes the tutorial. (C# API Ref ).-

Automatic Events

These events are available but require no implementation.

EventDescriptionProperties
game_load_startedTriggers 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_loadedTriggers 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_startedTracks purchases.
purchase_completedTracks purchases.
game_crashedRecords crash data. All crashes can be found in the Game Manager Crash Log.

Optional Events

These events are optional.

EventDescriptionProperties
gameplay_tutorial_skippedWhen the player skips the tutorial.-
gameplay_premium_spentWhen the player spends premium currency.name, amount, source, new_balance
gameplay_premium_gainedWhen the player gains premium currency.name, amount, source, new_balance
gameplay_resource_spentWhen the player spends game currency.name, amount, source, new_balance
gameplay_resource_gainedWhen the player gains game currency.name, amount, source, new_balance
gameplay_offer_shownWhen the player is shown an offer, deal, liveOps, or promotion.offer
Custom EventSet any game-specific custom event you need, and deliver it to your analytics services.name,parameters[]