Web SDK Basic Methods

Sessions

Session length is one of the most important parameters of an application.

By default, the session starts automatically right after SDK is initiated. But if it makes more sense to you, you are able to start a session later.

/**
* Starts session manually. Use this method if you want to start considering
* the session time later than the SDK was initiated.
*/

devtodev.startSession();

This method is not recommended to be repeatedly applied.

Usage example:

You can use this method to start counting the session length after Flash application is loaded and launched, not after container page is loaded.

ATTENTION! If you use an application running in fullscreen mode, it is necessary to call a special method at the moment of switching between display modes. In case application will be used in fullscreen mode without calling the method, session length will be counted incorrectly.

/**
* Full-screen view status
* @param {boolean} status - set true when the app switches to the full-screen mode,
* set false in other case
*/

devtodev.setFullScreenMode(status);

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. 

/**
* The event allowing to track the stage of tutorial a player is on.
* @param {number} tutorialStep - the latest successfully completed tutorial step.
* Use special values to record base evetns of the tutorial:
* -1 - Start the tutorial (at the beginning, before the first step is completed)
* -2 - Tutorial finished (instead of the last step number)
*  0 - Tutorial skipped (if user skipped the tutorial).
* Attention! The logic of the use of the Skip (0) constant in the Tutorial steps event
* is provided only in case a user has completely refused to pass the tutorial.
* After Skip (0) is used, no other values of the Tutorial steps event must be received.
*
* In other cases use step numbers. Make sure you use numbers above 0 numerating the steps.
*/

devtodev.tutorialCompleted(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.

/**
* Player has reached a new level
* @param {number} level - level reached by the player.
*/

devtodev.levelUp(level);

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

/**
* @param {number} level - player/character's "level"
* @param {Object} resources - Object with data about currencies. Optional.
* @param {Object[]} resources.balance -  Account balance of in-game currency by the end of level. * Optional.
* @param {Object[]} resources.balance[].currency - Game currency name
* @param {Object[]} resources.balance[].amount - Game currency amount
* @param {Object[]} resources.earned - Game currency earned during the level. Optional. 
* @param {Object[]} resources.earned[].currency - Game currency name
* @param {Object[]} resources.earned[].amount - Game currency amount
* @param {Object[]} resources.spent - Game currency amount spent during the level. Optional.
* @param {Object[]} resources.spent[].currency - Game currency name
* @param {Object[]} resources.spent[].amount - Game currency amount
* @param {Object[]} resources.bought - Game currency amount bought during the level. Optional.
* @param {Object[]} resources.bought[].currency - Game currency name
* @param {Object[]} resources.bought[].amount - Game currency amount 
*/

devtodev.levelUp(level, resources);

Example:

var resources = {
balance: [    //Account balance of in-game currency by the end of level
        {
            “currency” : "coins", //game currency name
            “amount” : 1000 //game currency amount 
        },
        {
            “currency” : "gold", //game currency name
            “amount” : 10 //game currency amount
        },
        …
    ],
earned: [ //Optional. Game currency earned during the level
        {
            “currency” : "coins",
            “amount” : 30000
        },
        …
    ],
bought: [ //Optional. Game currency amount bought during the level
        {
            “currency” : "gold",
            “amount” : 10
        },
        …
    ],
spent: [ //Optional. Game currency amount spent during the level

        {
            “currency” : "coins",
            “amount” : 50000 
        },
        …
    ]

};

devtodev.levelUp(4, resources);

Payment

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

/**
* Register transactions made through the platform's payment system.
*
* @param {string} transactionId - transaction ID
* @param {number} productPrice - product price (in user's currency)
* @param {string} productName - product name
* @param {string} transactionCurrencyISOCode - transaction currency (ISO 4217 format)
*/

devtodev.realPayment(transactionId, productPrice, productName, transactionCurrencyISOCode);

Example:

devtodev.realPayment(“12345”, 9.99, “Currency pack 2”, “USD”);

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.

/**
* Tracks in-app purchases.
*
* @param {string} purchaseId - unique purchase Id or name (max. 32 symbols)
* @param {string} purchaseType - purchase type or group (max. 96 symbols)
* @param {number} purchaseAmount - count of purchased goods
* @param {Object[]} purchasePrice - array including the names and amounts of
* the paid currencies (total cost - if several goods were purchased)
* @param {string} purchasePrice[].currency - game currency name
* @param {number} purchasePrice[].amount - currency amount
*/

devtodev.inAppPurchase(purchaseId, purchaseType, purchaseAmount, purchasePrice);

Example:

var purchasePrice = [
    {
        “currency” : "coins", //game currency name
        “amount” : 1000 //game currency amount 
    },
    {
        “currency” : "gold", //game currency name
        “amount” : 10 //game currency amount
    }
];

devtodev.inAppPurchase(“cloak”, “clothes”, 1, purchasePrice);

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 10 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. 

/**
* Tracks custom events.
* @param {string} eventName - event name
**/

devtodev.customEvent(eventName);

10 parameter names may be associated with any event:

Then use method:

/**
* Tracks custom events.
* @param {string} eventName - event name (max. 72 symbols)
* @param {Object[]} params - array of event parameters. Up to 10 params.
* @param {string} params[].name - parameter name (max. 32 symbols)
* @param {string} params[].type - parameter value type. Can be "double" or "string".
* @param {string|number} params[].value - parameter value. (max. 255 symbols)
**/

devtodev.customEvent(eventName, params);

Example:

var params = [
            {
                “name”: “score”,
                “type”: “double”,
                “value”: 100500,
            },
            {
                “name”: “type”,
                “type”: “string”,
                “value”: “fatality”,
            },
            … //up to 10 parameters.
        ];

devtodev.customEvent(“win”, params);

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
    /**
    * The method have to be used when entering the location.
    * @param {string} locationName - the name of location user entered.
    * @param {Object} startParams - location parameters object
    */
    devtodev.startProgressionEvent(locationName, startParams);

     

  2. Method endProgressionEvent when exiting (no matter if completed or not)  the location
    /**
    * The method have to be used when the location passing is over.
    * @param {string} locationName - the name of location user left.
    * @param {Object} endParams - location parameters object
    */
    devtodev.endProgressionEvent(locationName, endParams);

    Location parameters object contains:

    var params = {
        // Previously visited location (optional).
        "source" : "locationSource",
    
        // Location level of difficulty (optional).
        "difficulty" : 1,
    
        // Time spent in the location (optional).
        // 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.
        "duration" : 80,
    
        // State/result of the location passing (required).
        "success" : true,
    
        //User spendings within the location passing (optional).
        "spent" : [
            {
                "currency": "currency 1 name", // Currency name length max. 24 symbols.
                "amount": 1   // objects with amount value less than 1 are ignored
            },
            {
                "currency": "currency 2 name",
                "amount": 2
            }
        ],
        
        // User earnings within the location passing (optional).
        "earned" : [
            {
                "currency": "currency 1 name",
                "amount": 1 // objects with amount value less than 1 are ignored
            },
            {
                "currency": "currency 2 name",
                "amount": 2
            }
        ]
    };
    

     

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
var params = {};

// Specify the known location parameters:
// Passing on the first level of difficulty.
params["difficulty"] = 1;

// Before entering this location gamer passed the third location on the map “Village” (optional).
params["source"] = "Vilage step 02";

//The location passing starts (required).
devtodev.startProgressionEvent("Vilage step 03", params);

// ... Player passing the location.

// Player finishes passing of the third location on the map “Village”

// The location is passed successfully (required).
params["success"] = true;

// The passing took 189 seconds.
params["duration"] = 189;

// Location is passed for 54 turns. While the passing gamer used boost and bought extra 5 turns.
params["spent"] = [
    {
        "currency": "Turns",
        "amount": 54
    },
    {
        "currency": "Boost Bomb",
        "amount": 1
    },
    {
        "currency": "Extra 5 Turns",
        "amount": 1
    }
];

// Gamer finished the passing with 3 stars and gained 5 coins and 1200 score.
params["earned"] = [
    {
        "currency": "Stars",
        "amount": 3
    },
    {
        "currency": "Score",
        "amount": 1200
    },
    {
        "currency": "Coins",
        "amount": 5
    }
];

// The location passing is over (required).
devtodev.endProgressionEvent("Vilage step 03", params);

 

Analytics Integration
User profile