Collect data
Data collection is the process of gathering information on player’s behaviors during play such as login and currency acquistion. It is achieved at the client side by calling the correspoding methods written in some game scripts that SDK contains. Collected data is used as a basis of data analysis that leads to the generation of personalized or AI in-game shop offers.
The following explanations on collection data assume that you have installed the SDK with ShingGoong demo game. |
Where to find the reference script
The TPStashEvent
is the class that involves most of the available methods for data collection. To find the examples on TPStashEvent
, you can refer to Player.cs in Assets/ShingGoongDemo/Scripts/TentuplayRelated. It is is a component script of Player game object that exists in ShelterScene.



How to use data collection method
To make the data collection work, it is necessary to call the appropriate methods of TPStashEvent class for each game event.
Two of common game events are join events and login events. The following example script exhibits how to initialize TentuPlay and logs the join events of new users and login events. You can collect the data by writing one line of code for each event.
using UnityEngine;
using TentuPlay;
using TentuPlay.Api; // for collecting and uploading data
using UnityEngine.UI;
public class ExampleJoinScript : MonoBehaviour
{
// define variables
private string player_uuid = "TentuTestPlayer"; // player_uuid as a unique identifier of a player
// Start is called before the first frame update
void Start()
{
// initialize
TPStashEvent myStashEvent = new TPStashEvent();
// Join method when calling a new subscription event
myStashEvent.Join(player_uuid : player_uuid);
// Login method when calling user's login event
myStashEvent.PlayerLogin(player_uuid : player_uuid,
app_version : "1.0" // default is null. (optional)
);
}
}
If the data upload is successful, the events will be logged to the Unity Editor console as shown below.

See TentuPlay API Documentation for more information.