• Home  / 
  • Unity3D
  •  /  Add Unity Analytics to your Unity3D game today!

Add Unity Analytics to your Unity3D game today!

Should you use Unity Analytics?

Definitely!!!  If you’re building a game and expect to have anyone playing it, there’s really no good excuse not to use the Unity Analytics system.

The Unity Analytics system is free, easy to integrate, and if used properly can provide great insight into what your players are doing and how to make your game better.

With even the most basic Unity Analytics setup, you can track player growth and retention, with nothing more than the flip of a switch.

If you decide to go further though, the possibilities are amazing.

How do I enable Unity Analytics?

To enable the analytics system, you need to open the Services Tab

If you’re not logged in, you’ll see the Sign in button.

Sign into your Unity account.

Next you’ll see a screen to create your project, just click the Create button.

Click the button on Analytics to toggle it from Off to ON

Click the “Enable Analytics” button

If your game is targeted at kids, check the box.

Then click the Continue button

That’s it, basic analytics are enabled.  See how simple that was..

How Can I test it?

The first thing you can do is hit Play.

When you do, you should see data appear in the Validator (still on that analytics/services tab)

Checking out your data on the webpage

You can visit the analytics site here: https://analytics.cloud.unity3d.com

When you do, you’ll see your project but no data.

This is because there’s a delay in the data processing.  In my experience it can range anywhere from a few hours to a day.

So don’t worry, your data is probably getting written, just check back later to view it.

Custom Unity Analytics Data

What we have so far will give you some really useful info like Daily Active Users (DAU), Monthly Active Users (MAU), retention, session count, and more.

But to get the most out of the system, you really want to track actionable items.

Custom data is easy to track too though, it can be as simple as a single call to Analytics.CustomEvent, or you can build a dictionary of data and send that all at once.

Personally, I like to create a new class to handle wrapping all my analytics calls so that they’re not scattered throughout the project.

Let’s take a look at a sample of how I prefer to setup mine.

I start by preventing the object from getting destroyed when we switch scenes (I always include this object in my opening/loading/menu scene).

Then I’ll register for events on things I care about.  In this example, I’m registering with our level controller and player controller events.

Level Events

The LevelController event will happen whenever a player beats a level, and we simply send an event with a string that appends the levelName.

Since this data is pretty simple, I prefer to have it in an easy to use format that I can build funnels on in the Analytics webpage UI.

Player Events

The OnPlayerDied event has a bit of extra info I want though.  In there, I track the position the player died at and what killed them.

I then put that data into a dictionary and pass that dictionary into the CustomEvent for analysis later.

Analytics.FlushEvents

The last thing to notice is in the OnDestroy method.  Here, I force the analytics system to push the data up to the servers.

To minimize networking data, the system determines when to send updates on it’s own.

If we don’t call FlushEvents on close, we may not get the players analytics data until the next time they launch the game.

If they never launch it again, we’ll never get the data, and never have any insight into why they didn’t come back.

 

Conclusion

If you’re not using analytics, just turn it on…  Even if you’re not sure what data you want to capture, or what you’ll do with it…. just turn it on.

And once you have some idea of even the basic things you may care about, where’d my players die, how many levels are they beating, etc… you can start tracking that data easily.

Maybe you’ll find out “NOBODY beating level 3!”, or “Nobody’s activating this special ability”…  then you can adjust level 3, change the instructions or controls for the special ability, and compare..

Or alternatively you can make wild guesses about what your players are doing and what they like…. but I think you’ll prefer getting the data 🙂

  • A Person

    Great, Thanks!!