The basic methods of devtodev SDK for Unity

Tutorial steps

The event allows to evaluate the effectiveness of the tutorial steps system. The event should be sent at the end of each tutorial step indicating the number of every passed step as a parameter. 

Use the following constants to specify basic events of tutorial steps:

  • DevToDev.TutorialState.Start or -1 - at the beginning, before the first step is completed;

  • DevToDev.TutorialState.Finish or -2 - instead of the last step number;

  • DevToDev.TutorialState.Skipped or 0 - if user skipped the tutorial.

In other cases use step numbers. Make sure you use numbers above 0 numerating the steps.

Attention! The logic of the use of the Skipped constant in the Tutorial steps event is provided only in case a user has completely refused to pass the tutorial. After Skipped is used, no other values of the Tutorial steps event must be received.

/// <summary> The event allowing to track the stage of tutorial a player is on. </summary>
/// <param name="tutorialStep"> The latest successfully completed tutorial step </param>
DevToDev.Analytics.Tutorial(int tutorialStep);

Levelling up

You can analyse the distribution of the players over the levels. The event is sent over reaching a new level by a player.

/// <summary> Player has reached a new level </summary>
/// <param name="level"> Level reached by the player </param>
DevToDev.Analytics.LevelUp(int level);

To track the average account balance of in-game currency by the end of each level, please also provide the list of currency names and their amount.

/// <summary> Player has reached a new level</summary>
/// <param name="level"> Player level </param>
/// <param name="resources"> Dictionary with the currency names and amounts </param>
/// <example>
/// <code>
///    Dictionary<string, int> resources = new Dictionary<string, int>();
///    resources.Add("Currency name 1", 1000);
///    resources.Add("Currency name 2", 10);
/// </code>
/// </example>
DevToDev.Analytics.LevelUp(level, resources);

To track the average amount of in-game currency earned or purchased during a level, it is necessary to send a special event after each time an in-game account is replenished.

/// <param name="currencyName"> Currency name (max. 24 symbols) </param>
/// <param name="currencyAmount "> The amount an account has been credited with </param>
/// <param name="accrualType"> The way the currency was obtained: earned or purchased </param>
DevToDev.Analytics.CurrencyAccrual(int amount, string currencyName, AccrualType accrualType);

AccrualType can take one of following values:

public enum AccrualType {


To track the payments, add this event right after the platform confirms that the payment went through.

/// <summary> Register transactions made through the platform's payment system. </summary>
/// <param name="paymentId"> Transaction id </param>
/// <param name="inAppPrice"> Product price (in user's currency) </param>
/// <param name="inAppName"> Product id (product name) </param>
/// <param name="inAppCurrencyISOCode"> Transaction currency (ISO 4217 format)</param>
DevToDev.Analytics.RealPayment(string paymentId, float inAppPrice, string inAppName,
                               string inAppCurrencyISOCode);

In-app purchases

To track expenditures of in-game currency and the popularity of the products, add this event right after a purchase is made.

/// <summary> In-app purchase with a definite ID. </summary>
/// <param name="purchaseId"> Unique purchase ID  or name (max. 32 symbols)</param>
/// <param name="purchaseType"> Purchase type or group (max. 96 symbols)</param>
/// <param name="purchaseAmount"> Number of purchased goods </param>
/// <param name="purchasePrice"> Cost of purchased goods (total cost - if several goods were purchased)</param>
/// <param name="purchasePriceCurrency"> Currency name (max. 24 symbols)</param>
DevToDev.Analytics.InAppPurchase(string purchaseId, string purchaseType, int purchaseAmount,
                                 int purchasePrice, string purchaseCurrency);

In case a product was bought for several game currencies at onсe, it is necessary to make a dictionary including the names and amounts of the paid currencies.

Dictionary<string, int> resources = new Dictionary<string, int>();
resources.Add("currency_1", 120);
resources.Add("currency_2", 29);
// …and so on…

DevToDev.Analytics.InAppPurchase(string purchaseId, string purchaseType, int purchaseAmount,
                                 Dictionary<string, int> resources);

Custom Events

If you want to count the events which are not among basic, use custom events.

The event must have a unique name and can include up to 20 parameters. The maximum length of the event name is 72 symbols.
Every parameter inside one event must have unique name. The maximum length of the parameter name is 32 symbols. 
The values of parameters can be String or number type (int, long, float, double). The maximum length of parameter value is 255 symbols. 

Attention! No more than 300 variants of custom event names can be used for one project. Try to enlarge events in meaning by using event parameters. Events that didn't get into the limit of unique event names will be discarded.

For a string parameter it is acceptable to use not more than 50000 of unique values for the whole event use history. In case the limit of unique values is exceeded the parameter is ignored. 
Therefore we recommend not to set user IDs and Unix time as parameter values of custom events. Try to integrate parameter values if they have a very large variability. Otherwise it will be very difficult to analyse the data or after some time it may be even ignored 
We strongly recommend not to change the type of data transferred in the parameter over time. In case you change the data type in parameter, in devtodev database it will appear one more parameter in the event with the same name but with different data type.

The report building with such parameter will be quite difficult. 

/// <param name="eventName"> Event name </param>
DevToDev.Analytics.CustomEvent(string eventName);

10 parameter names may be associated with any event:

DevToDev.CustomEventParams customEventParams = new DevToDev.CustomEventParams();
customEventParams.AddParam("double", 1.12);
customEventParams.AddParam("int", 145);
customEventParams.AddParam("long", 123L);

Then use method:

/// <param name="eventName">Event name</param>
/// <param name="eventParams">Event parameters</param>
DevToDev.Analytics.CustomEvent(string eventName, DevToDev.CustomEventParams eventParams);

Progression event

First of all, the event is used for the games with short (within one game session) locations, game levels. The event allows you to gather data on passing the locations and get statistics on parameters which vary during the the location passing.

Developer must use these 2 methods:

  1. Method StartProgressionEvent when enetring the location
    /// <param name="eventId"> The name of location user entered </param>
    /// <param name="eventParams"> Instance of progression parameters class </param>
    DevToDev.Analytics.StartProgressionEvent(string eventId, LocationEventParams eventParams);


  2. Method EndProgressionEvent when exiting (no matter if completed or not)  the location
    /// <param name="eventId"> The name of location user left </param>
    /// <param name="eventParams"> Instance of progression parameters class </param>
    DevToDev.Analytics.EndProgressionEvent(string eventId, LocationEventParams eventParams);

    LocationEventParams - the class inherited from ProgressionEventParams. Use it to describe location parameters. 

    LocationEventParams class methods:

    /// <summary> Location level of difficulty (optional). </summary>
    /// <param name="difficultyLevel"> Level of difficulty </param>
    SetDifficulty(int difficultyLevel);
    /// <summary> Previously visited location (optional). </summary>
    /// <param name="locationName"> Previously visited location name </param>
    SetSource(string locationName);
    /// <summary> State/result of the location passing (required). </summary>
    /// <param name="isCompleted"> True if location is successfuly passed </param>
    SetSuccessfulCompletion(bool isCompleted);
    /// <summary>Time spent in the location (optional).
    /// <para>In case the parameter is not specified by the developer, it will be automatically calculated
    /// as the date difference between StartProgressionEvent and EndProgressionEvent method calls.</para>
    /// </summary>
    /// <param name="duration"> Time in seconds </param>
    SetDuration(long duration);
    /// <summary> User spendings within the location passing (optional). Dictionary key max.length is 24 symbols.</summary>
    /// <param name="spent"> User spendings </param>
    SetSpent(Dictionary<string, int> spent);
    /// <summary> User earnings within the location passing (optional). </summary>
    /// <param name="earned"> User earnings </param>
    SetEarned(Dictionary<string, int> earned);


Attention! The user can be only in one location at the same time. When moving to another location (including embedded), the previous location must be completed. Information on locations, the passing of which was not completed by calling EndProgressionEvent method during the game session (the call of EndProgressionEvent method is not integrated; user unloaded the application from the device memory; there was an application crash) do not fall in the statistics.

Let’s analyse the example of event integration on match3 game with location map:

// Player comes to the third location on the map “Village” while following the game map. 
// Create a parameters object
LocationEventParams locationParams = new LocationEventParams();

// Specify the known location parameters:
// Passing on the first level of difficulty.

// Before entering this location gamer passed the third location on the map “Village” (optional).
locationParams.SetSource("Vilage step 02");

//The location passing starts (required).
DevToDev.Analytics.StartProgressionEvent("Vilage step 03", locationParams);

// ... Player passing the location.

// Player finishes passing of the third location on the map “Village”
// Create a parameters object
LocationEventParams locationParams = new LocationEventParams();

// The location is passed successfully (required).

// The passing took 189 seconds.

// Location is passed for 54 turns. While the passing gamer used boost and bought extra 5 turns.
Dictionary<string, int> spent = new Dictionary<string, int>();
spent["Turns"] = 54;
spent["Boost Bomb"] = 1;
spent["Extra 5 Turns"] = 1;

// Gamer finished the passing with 3 stars and gained 5 coins and 1200 score.
Dictionary<string, int> earned = new Dictionary<string, int>();
earned["Stars"] = 3;
earned["Score"] = 1200;
earned["Coins"] = 5;

// The location passing is over (required).
DevToDev.Analytics.EndProgressionEvent("Vilage step 03", locationParams);
Analytics integration
User profile