Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved How to make chart from custom event

Discussion in 'Unity Analytics' started by omanuke, Jul 4, 2022.

  1. omanuke

    omanuke

    Joined:
    May 5, 2017
    Posts:
    30
    My app sends custom event 'playerCount' which has two parameters 'roomName' of string and 'count' of int.
    I wanna visualize this data with line chart which indicates the transition of player count in each room for every room.
    I searched how to query custom event with parameter but I can't find.
    Now, is it possible? Or, query with custom event and parameter isn't implemented yet?
     
  2. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    Hi @omanuke

    If you have followed "Record Custom Events" documentation and have two parameters,
    the code should look like this:

    Code (CSharp):
    1. Dictionary<string, object> parameters = new Dictionary<string, object>()
    2. {
    3.     { "roomName", "room1" },
    4.     { "count", 1},
    5. };
    6. AnalyticsService.Instance.CustomData("playerCount", parameters);

    then you need to make sure the custom event has a schema defined in the Event Manager:

    upload_2022-7-4_9-28-40.png


    Once you have created the customer event in the Event Manager, you can then add the parameters here:

    upload_2022-7-4_9-34-52.png


    These custom parameters can be events that clearly state what the player is doing when. E.g. enteredRoom, with a roomName and perhaps even previousRoom parameter.

    upload_2022-7-4_9-44-24.png


    This data can then be visualized in the Data Explorer, this is where you can add metrics and events and visualize them by default on a line chart.

    upload_2022-7-4_9-47-5.png

    It might be worth taking a look at the Events Tracking documentation for best practices regarding customer events and parameters.

    I hope that helps.
     
  3. omanuke

    omanuke

    Joined:
    May 5, 2017
    Posts:
    30
    My app can send event properly.
    I read the article you pasted but still I didn't get how.
    OK, I can use a parameter to group. Can I use the value of count parameter instead of aggregated Sum?
    upload_2022-7-4_19-19-16.png
     
  4. omanuke

    omanuke

    Joined:
    May 5, 2017
    Posts:
    30
    If I try to add count parameter, count parameter is used for filter, not plot value.
    upload_2022-7-4_19-23-41.png upload_2022-7-4_19-24-57.png
     
  5. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    Maybe it would be better to name the Event 'roomEntered'?

    Perhaps you could use an SQL Query?

    E.g.
    Have an event called 'enteredRoom' which is recorded every time a player enters the room.
    The parameters could then be 'roomName' and possibly 'previousRoom'.

    This example is a SQL query you could use.
    -- Rooms by Popularity in Last 30d
    Select event_json:roomName::string , count(distinct USER_ID) as players
    from events
    where EVENT_NAME = 'roomEntered'
    and EVENT_DATE > CURRENT_DATE - 31
    group by 1
    order by 2 desc


    You can then see the results on a chart with roomName on the X-Axis and Players on the Y-Axis, however it might be harder to read if you visualize it on a Line Chart.

    upload_2022-7-4_14-46-50.png

    Are you referring to a line chart as a tree or hierarchy diagram?

    If you'd still like to use Data Explorer then you can set it up like this:
    + Add Event
    Event = enteredRoom
    Aggregated by = Unique Users
    Group By = Event Parameter : roomName


    I hope this helps
     
  6. omanuke

    omanuke

    Joined:
    May 5, 2017
    Posts:
    30
    Event_json is the answer what I've been seeking and couldn't reach.
    Now, I understand 'event_json' is written in the document but I couldn't find it.
    Thanks!
     
    Julian-Unity3D likes this.
  7. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    I'm glad I could be of assistance.
    Thanks