Implementing Analytics
How to trigger analytics events in game code, and which obligatory (and optional) events to fire through Pley SDK AnalyticsKit.
When launching a game through Pley, a set of analytics events is required for your game to function. This article is a how-to guide for implementing events correctly into the game code.
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 have 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 in the game code.
- Optional (Gamesite): Provide Pley with your Google Tag Manager ID, and events will be forwarded from the gamesite. GTM can then send the analytics to any attribution or analytics service you use.
- Optional (Headless Destination): Catch Pley analytics on your self-built headless gaming destination with the 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");
}
Article: List of Pley Analytics Events
How to get analytics data to your preferred analytics service
Event data is always visible in the Game Manager. However, you can also send the analytics events into the analytics service of your choice.
- Implement analytics into the game code according to this article.
- Provide Pley with your Google Tag Manager ID.
- Begin receiving event data from the Pley Game Site within 48 hours.
- Set up the Google Tag Manager to forward event data to whichever analytics service you use.
Unsure of how to do it? Reach out to us at Pley to receive our GTM project template.
Are you running a self-built headless gaming destination on the web? Read more about analytics here:
Updated 9 days ago