BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Unity Launches Analytics on iOS and Android

Unity Launches Analytics on iOS and Android

Unity last week announced the launch of Unity Analytics, a service which assists game developers in gaining an understanding into the behaviour of their players. The service is currently in an open beta with support for the iOS and Android platforms only.

Unity is both a cross-platform game engine and design suite that enables developers to create games for multiple platforms using a single code-base. Supported languages include C#, Unity Script (JavaScript for Unity) and Boo; with most usage attributed to C#. Unity currently supports 17 platforms across web, mobile, desktop and console, including iOS, Android, BlackBerry 10, Windows Phone 8, PlayStation 4/Vita, Xbox One/360 and Wii/Wii U. Cross-platform support has been a major attraction for mobile developers in particular, with a number of app store topping games utilising the engine; including Temple Run, Angry Birds Epic, Bad Piggies and Shadow Blade.

During the open beta the following feature set will be available to early adopters:

  • Metric Monitor - Dashboard which provides with a high level overview of key performance indicators e.g. number of players, session duration and retention.
  • Segment Builder - Support for segmentation of players based on user attributes or game behaviour patterns.
  • Funnel Analyser - Analyse player drop-off to determine where users lost interest.
  • Data Explorer - Take a deep-dive into analytics data to determine how specific audiences perform e.g. compare retention rates of iOS and Android users.
  • Custom Data Collection - Capture custom data to track what's important to you e.g. find out if your in-app purchase revenue is legitimate or fraudulent through receipt verification.

The analytics add-on is available as a separate Unity package and can be download from the Asset Store (accessed via the Unity Editor's Assets menu). Once the package has been added to a Unity project the SDK must be initialised by adding a new C# script to the project:

using UnityEngine;
using System.Collections;
using UnityEngine.Cloud.Analytics;

public class UnityAnalyticsIntegration : MonoBehaviour {

  // Use this for initialization
  void Start () {
    const string projectId = "PROJECTID-GOES-HERE-66fb5cf028d728bb";
    UnityAnalytics.StartSDK (projectId);
  }

}

The script should be attached to a GameObject within any Scene of your game (the first Scene is recommended to capture as many events as possible). This basic level of integration will enable tracking of key performance indicators such as player numbers and session duration. To gain access to the additional features described previously developers can make manual calls to the analytics API.

To record events related to monetisation e.g. completion of in-app purchases, developers can invoke the API's transaction method, passing information about the purchase:

// Reference the Unity Analytics SDK package
using UnityEngine.Cloud.Analytics;

// Use this call for each and every place that a player triggers a monetization event
UnityAnalytics.Transaction(string productId, decimal price, string currency, string receipt, string signature);

To track game specific events developers can use the API's CustomEvent method, which accepts an event name and dictionary of additional parameters:

// Reference the Collections Generic namespace
using System.Collections.Generic;

int totalPotions = 5;
int totalCoins = 100;
UnityAnalytics.CustomEvent("gameOver", new Dictionary<string, object>
{
    { "potions", totalPotions },
    { "coins", totalCoins }
});

Note that a number of restrictions apply to the CustomEvent API:

  • The request dictionary must contain no more than 10 parameters.
  • The overall length of the request dictionary must not exceed 500 characters.
  • No more than 100 custom events can be published per client in an hour.
  • Each game is limited to 50 custom event types/names.

Lastly, developers can analyse player demographics using the segmentation methods exposed by the API:

SexEnum gender = SexEnum.F;
UnityAnalytics.SetUserGender(gender);

int birthYear = 2014;
UnityAnalytics.SetUserBirthYear(birthYear);

Developers with a Unity account can sign up for the beta on the Unity site. The Analytics beta is also available to new users who can download a standard version of Unity engine and tool suite free of charge, if their/their company's revenue does not exceed $100,000. Those not eligible for the standard version can purchase a Pro license for $1,500 which includes additional tool suite and engine add-ons. For further information on Unity pricing and licensing options refer to the Unity pricing guide and FAQ.

Rate this Article

Adoption
Style

BT