Cordova SDK Basic Methods

Attention! The support of the SDK for this platform has been suspended!


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:

  • -1 - at the beginning, before the first step is completed;
  • -2 - instead of the last step number;
  •  0 - in case 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 (0) constant in the Tutorial steps event is provided only in case a user has completely refused to pass the tutorial. After Skipped (0) is used, no other values of the Tutorial steps event must be received.

/**
* 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).
* In other cases use step numbers. Make sure you use numbers above 0 numerating the steps.
*/

plugins.devtodev.tutorialCompleted(tutorialStep);

Levelling up

You can analyse the distribution of the players over the levels. The event should be send right after the player reached the next level. 

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

plugins.devtodev.levelUp(level);

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

/**
* @param {number} level - player/character's "level"
* @param {Object} resources - Object with data about currencies. Optional.
*/

devtodev.levelUp(level, resources);

Example:

var resources = {
    "gold" : 100.25,
    "silver" : 1200
};
plugins.devtodev.levelUp(level, resources);

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

/* *
* @param {string} currencyName - currency name (max. 24 symbols)
* @param {number} currencyAmount - the amount an account has been credited with.
* @param {string} accrualType - the way the currency was obtained: earned or purchased.
* Attention! accrualType can take one of following values: "purchased" or "earned"
*/

plugins.devtodev.currencyAccrual(currencyAmount,currencyName,accrualType);

 

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)
*/

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

Example:

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

In-app purchases

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

/**
* 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 {number} purchasePrice - array including the names and amounts of
* the paid currencies (total cost - if several goods were purchased)
* @param {string} purchaseCurrency - game currency name
*/

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

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

plugins.devtodev.inAppPurchaseWithResources(purchaseId, purchaseType, purchaseAmount, resources);

Example:

var resources = {
    "wood" : 12,
    "silver" : 36.6,
};
plugins.devtodev.inAppPurchaseWithResources(“cloak”, “clothes”, 1, 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 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
*/

plugins.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.
*/

plugins.devtodev.customEvent(eventName, params);

Example:

var parameters = {
    'result' : 'Victory',
    'location' : 12,
    'score' : 12.312
};
plugins.devtodev.customEvent('eventName', parameters);

 

Analytics Integration
User profile