Saturday, May 2, 2015

Unity Analytics

Recently I was asked to investigate integrating analytics into a game I'm working on, and I decided to write a little post about it and my experience with analytics as a whole.


Does anyone actually use analytics?

The obvious answer is yes, people use analytics; otherwise, it wouldn't be a topic of discussion at GDC or this post.  But my question really pertains to, does everyone use analytics?  Sure, people integrate analytics into their game, but do they actually understand how to interpret the data they are tracking?  That's my issue really.  I feel like sometime the desire for analytics data is like "We need to integrate analytics!  For the love of all things sacred, if they aren't being recorded, the game will most surely fail!"
But then those who request the analytics get them and it's like, "What do we do with all this data?!  I'm drowning in piles and graphs and pie charts of data!"  So that's my first...disclaimer?  Sure, disclaimer.  If you're going to integrate analytics, make sure you have a plan on how the data will be read and used.  I contemplated on integrating analytics into Battle High 2, and if I were to do so, I would probably try and use it to analyze the following:
  • Which characters are the most popular.  If a character is neglected, maybe it needs some buffing; if a character is overused, maybe it needs some nerfing.  Also track their win / loss percentages.
  • Maybe track the highest combo per character per match.  If a recorded combo seems ridiculously high, maybe there is a problem with that character.
  • Are the journal entries / challenges / achievements actually being finished
That's really it for now.  I usually undershoot what to track; I know some designers who could probably fill a list of 100 items to track on Battle High 2 alone, but again, would I take / have the time to analyze all those results properly.  As someone said to me, "Tracking the data is easy; analyzing the data is the hard part."

Unity Analytics

Anyway, the game I've been working on was made with Unity, so I decided to try Unity's new analytics plugin, aptly named Unity Analytics.  It's in beta, but what I liked about it was that it was extremely easy to integrate.


Creating a Project

So if you're interested in trying Unity Analytics for your project, you should go here first: .  You'll have to be logged into your account, and for now, it's available for all users during this beta.
When creating a project, you'll be asked a few questions such as the project name and organization and version of Unity.  There is then a question about whether or not your game is directed at minors, since due to some laws, the type of data collected is limited when creating a game for minors.
The only thing that was a little confusing for me was the question about the Google API Key.  I wasn't sure if this was Google Analytics or some other key, but it's the key used by Google if your game has IAP purchases and is integrated into the Google Play Store: 

It's an example, but that long string is an example key used for the Google API Key.

Once this is done, your project is ready to start integration.

Integrating Unity Analytics

Another thing I liked about this process is that there is a built-in integration tutorial into the website, and even better it allows you to test if your integration is working.  The initial integration involves a few steps:
  • Downloading the Unity Analytics SDK, which can be found in the Unity Asset Store
  • Creating an object that calls UnityAnalytics.StartSDK (projectId)

Project ID is supplied in the integration steps. You can then test it through the website, almost immediately, to see if your game, even in the editor, is sending these calls properly. There are then steps to try and do monetization analytics, custom events, and player definitions.
Our game doesn't really require monetization analytics -- which I believe is why you are asked for the Google API key -- and player definition yet, but the custom event integration is pretty painless.
All you do is call UnityAnalytics.CustomEvent. It takes two arguments, a string -- the name of the event -- and then a Dictionary, whose keys are strings and values are objects -- extra parameters about the custom event.
The interesting thing though is that Unity analyzes and processes the data, so the way you send custom events is unique.

Analysis Points

Disclaimer: I am still new to Unity Analytics and my interpretation of Analysis Points could be inaccurate.

Every project you make uses what is known as Analysis Points. These points can be better understood by using this post. From my understanding, they are depending on the different types of custom events you can track. The evaluation is a little interesting, but all-in-all, it forces you to be very careful about how you track said events.

For example, let's say I have an event that results in true or false. "Accepted Mission". So, to call it, I would call:

UnityAnalytics.CustomEvent("Mission Status", 
     new Dictionary());

Now what if I wanted a custom event that is simply mission failed or passed.

UnityAnalytics.CustomEvent("Mission Status", 
     new Dictionary()
          {"Success", true}

Now the problem here is that my custom parameter, Success, will actually cost 10 analysis points -- you start with 1,000 per project -- because it'll be converted to a string as opposed to an integer. Now, I could try doing something like 0 for false and 1 for true, but the problem is Unity Analytics will average these values so reading them will become difficult. A smarter approach would probably be to do two different CustomEvents with no custom parameters such as

UnityAnalytics.CustomEvent("Mission Failed", 
     new Dictionary());

UnityAnalytics.CustomEvent("Mission Success", 
     new Dictionary());

Using two simple Custom Events will only cost 2 analysis points, 1 each. Also, as a heads-up, I have found that using an enum in the dictionary, will not work or register. Sending a separate Custom Event based for each enum would probably be more efficient.



So that's all I really have notes on, the integration. Unfortunately, the game I'm referring to hasn't been updated with the new analytics yet, so there hasn't been a need to try and analyze any data. There seems to be a lot of advance tools provided by Unity for funneling data, testing, defining the users -- male, female, age, etc.
Unity Analytics really comes down to another reason why I like Unity as a whole. The Unity Engine isn't the most powerful, but it's approachable and with the addition of new features such as this, Unity Ads, and UNET, Unity continues to provide a lot of new features for their user base so they can utilize features that a lot of other successful games utilize.
Now, unfortunately, I'm not sure what the future plans of Unity Analytics will be. Will they charge for more analysis points? Will they give users less then 1,000 once out of beta? I'm not sure, but if you do what to integrate analytics in your Unity game, it's a great place to start!