How to use analytics in Unity

Let’s go over how to enable and use analytics in Unity.

First, open the Services window, click on Analytics and then enable:

To view analytics events click on “Go to dashboard”. In older versions of Unity it was possible to view the events in the editor but that has now been removed:

Open up the script you want to track events on and add the using directive UnityEngine.Analytics:

Add a public function for the event and add Analytics.CustomEvent with a suitable description:

Lastly, add the script to a buttons OnClick event:

Good luck!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store