Using the AnalyticsTracker component

Now, one of the simplest ways to track when something occurs is through the editor itself, making use of the Analytics Tracker (Script) component. For example, perform the following steps when you want to track whether players are using the Pause menu.

  1. Open the Gameplay scene by going to the Project window and then to the Assets\Scenes folder. From there, double-click on the Gameplay scene.
  2. From the Hierarchy window, expand the Canvas object. From there, select Pause Menu.
  1. From the top bar, select Component | Analytics | AnalyticsTracker to add the component to our selected game object:
  1. Next, we will need to come up with an Event Name to use. In this case, I used Paused. Then, under Trigger, select the dropdown and the On Enable option.

This means that if we turn on the pause menu (or rather when it is enabled), an event will be sent. Note that this is different from the On Start event due to that event only happening once when it is initially turned on.

  1. Now, start the game and then pause the game. If you go to the Services tab and open up Analytics, you should note from the Validator that a new event has been added:

In addition to seeing this data in the Services tab, we can also see it in the dashboard.

  1. Go ahead and scroll up in the Services tab and select the Go to Dashboard button on the top-right portion of the tab. From there, click on the Data Explorer option.
  2. From the Data Explorer tab, you'll see a section for Metrics and Custom Events. You'll also see a chart that shows the DAU (Daily Active Users) that have been playing your project. We can use this menu to observe whenever the Paused event is called.
If you have just created the event, it may take up to 12 hours for the information to be received. Go ahead and check back later whether that's the case.
  1. Click on the + button to the left of Custom Event to add a Custom Event to this graph. Then, select the Custom Event dropdown and select Paused. Since we have just made the event, we won't see it in previous dates in Analytics, but we can see it a little easier if we click on the Column Chart button to change how the data is displayed:

Notice that when we scroll down we can see that the Data Explorer now shows that the Paused event has been called!

In addition to the calling event, you can also add parameters to the events in a similar manner to how Unity's UI system works. For more information on that and the Analytics Tracker component, check out https://docs.unity3d.com/Manual/UnityAnalyticsAnalyticsTracker.html.