Skip to content



Folders and files

Last commit message
Last commit date

Latest commit



72 Commits

Repository files navigation

Getting started with Infinario Unity SDK (in 6 minutes)

Infinario Unity SDK is available in this Git repository: It provides tracking capabilities for your application.


Download or clone this repository from your command line: git clone


Basic Tracking

To start tracking, you need to know your projectToken. To initialize the tracking, simply get an instance of the Infinario class and call just once Initialize:

var infinario = Infinario.Infinario.GetInstance();

//or if you want to track app version as well, third parameter is instance
infinario.Initilize("projectToken", "1.0.0", "");

Now you can track events by calling the Track method:


What happens now, is that an event called my_user_action is recorded for the current player.

Identifying Players

To control the identity of the current player use the Identify method. By calling


you can register a new player in Infinario. All events you track by the Track method from now on will belong to this player. To switch to an existing player, simply call Identify with his name. You can switch the identity of the current player as many times as you need to.

Anonymous Players

Up until you call Identify for the first time, all tracked events belong to an anonymous player (internally identified with a cookie). Once you call Identify, the previously anonymous player is automatically merged with the newly identified player.

Adding Properties

Both Identify and Track accept an optional dictionary parameter that can be used to add custom information (properties) to the respective entity. Usage is straightforward:


infinario.Track("my_player_action", new Dictionary<string,object> {
                                                        {"daily_score", 4700}

infinario.Identify("", new Dictionary<string,object> {
                                                        {"first_name", "John"},
                                                        { "last_name", "Doe" }
infinario.Update(new Dictionary<string,object> {{"level", 1}}); // A shorthand for adding properties to the current customer


infinario.Track("my_player_action", {"daily_score": 4700});

infinario.Identify("", {"first_name": "John",
"last_name": "Doe"});

infinario.Update({"level": 1}); // A shorthand for adding properties to the current customer

Player Sessions

Session is a real time spent in the game, it starts when the game is launched and ends when the game goes to background. But if the player returns to game in 60 seconds, game will continue in current session. Tracking of sessions produces two events, session_start and session_end. Put below code to your MonoBehaviour object like MainCamera.


Infinario.Infinario infinario;

void Start () {
    infinario = Infinario.Infinario.GetInstance();


void OnApplicationPause(bool pauseStatus) {


Infinario.Infinario infinario;

function Start () {
    infinario = Infinario.Infinario.GetInstance();


function OnApplicationPause(pauseStatus: boolean) {

Both events contain the timestamp of the occurence together with basic attributes about the device (OS, OS version, SDK, SDK version and device model). Event session_end contains also the duration of the session in seconds.

Virtual payment

If you use virtual payments (e.g. purchase with in-game gold, coins, ...) in your project, you can track them with a call to TrackVirtualPayment.

infinario.TrackVirtualPayment ("gold", 3, "sword", "sword_type”);


The SDK automatically adds timestamps to all events. To specify your own timestamp, use one of the following method overloads:

infinario.Track("my_player_action", <long_your_tsp>);
infinario.Track("my_player_action", <properties> , <long_your_tsp>);	

Get Segment for player

To obtain player's segment information form segmentations you can use method GetCurrentSegment. You have to specify projectSecret (this is different than projectToken - you can find it in project overview). The second parameter is segmentationId (obtained from last part of url, when creating or viewing segments). The last one is your callback method with 3 parameters:

  • boolean type specifing if retrieving of segment was successfull
  • InfinarioSegment type with the our desired information about players segment
  • string information about errors that occured
 infinario.GetCurrentSegment(projectSecret, segmentationId, OnSegmentReceiveCallback);

 private void OnSegmentReceiveCallback(bool success, InfinarioSegment infinarioSegment, string error)
        if (success)
            // Do stuff according to segment type

InfinarioSegment class object returned in OnSegmentReceiveCallback contains public methods:

  • GetName() returning string name of the segment where player belongs
  • GetSegmentationName() returning string name of segmentation
  • GetSegmentIndex() returns integer identifying the order of current segment in segmentation (starting with 0)

Offline Behavior

Once instantized, the SDK collects and sends all tracked events continuously to the Infinario servers.

However, if your application goes offline, the SDK guarantees you to re-send the events once online again (up to a approximately 5k offline events). This synchronization is transparent to you and happens in the background.

Final Remarks

  • Make sure you create at most one instance of Infinario during your application lifetime.
  • If you wish to override some of the capabilities (e.g. session management), please note that we will not be able to give you any guarantees.