Unity Gaming Services Analytics: Zoo
Objective: Setup analytics to track what exhibits are visited in Family Zoo app
Unity Gaming Services has Analytics in beta, while this service is a little harder to setup, it is more flexible in its implementation. Though previously described the setup process is recapped. A GameManager to check permissions and initialize UnityServices is required, shown below.
The project’s mainfest.json file within Packages folder requires adding a line, “com.unity.services.analytics”: “3.0.0-pre.3” to the end of the file using a text editor, such as Notepad.
From the services window go to the dashboard and log into Unity Gaming Services. Select Analytics and add new and select custom event. Named it exhibits_Event, and give it a description. Enable exhibits_Event.
Similarly select add new then choose parameter from the menu. Create six Boolean parameters, named after each exhibit. Return to the Analytics > Event Manager from left menus, and from events tab, select exhibits_Visited. Assign each newly created parameter to this event. Select Analytics > Data Explorer and assign the event six times, but adding a different parameter, as shown below. Enter the value for each parameter to be measured. The report should be similar to that shown below. Apply and save this report, which will be used later to visualize which exhibits were visited.
The custom event and parameters are now set up in Unity Gaming Services, but need to be linked user selection in the Family Zoo app. The interactive map has six buttons corresponding to each exhibit, as shown below.
In the Hierarchy, these buttons are organized within the Habitat object as shown. Create an AnalyticsTracker script and add it to Habitat game object.
This script uses a Dictionary parameters array to uniquely communicate which button or exhibit has been selected. The use of object to define the dictionary allows the use of any string, int, float or bool variable. Each parameters dictionary element contains a reference to its Analytics parameter defined in Unity Gaming Services, followed by its value. The ExhibitVisitedAnalytics() method is called by the On Click() method on the button and requires the int exhibitID. CustomData reports to exhibits_Visited the parameters element corresponding to the exhibitID.
The Big_Cats_Button’s On Click() events are shown below. The first event activates the Card_Panel, the second defines the exhibit to display on the card panel. The third event has Habitat assigned so that the ExhibitsVisitedAnalytics method on the AnalyticsTracker script can be passed the eventID, unique to each button. All six buttons use the Habitat and its script, each with a unique int corresponding to its exhibits parameters element. There is no need to add a script to each button.
After users have used the Family Zoo app the data is reported to Unity Gaming Services. Run the report created earlier to view which exhibits are visited.
While a histogram is shown above, there are other graphical views for data.