Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Resolved Is there a way to just send an event with an int? it seems I can only send dictionaries

Discussion in 'Unity Analytics' started by humanMusic, Jun 20, 2024.

  1. humanMusic

    humanMusic

    Joined:
    May 16, 2017
    Posts:
    21
    Hi,

    I'm trying to wrap my head around these new analytics. right now I'm using Analytics.CustomEvent for any custom analytics I want to send. But it only accepts an int. For example I want to send the number of levels completed in a session. something like levelsCompletedInSession = 2. Do I have to create a dict just to send this?
     
  2. hotlabs

    hotlabs

    Joined:
    Apr 11, 2021
    Posts:
    20
    you can check my post here: although Unity at the moment seems having some problem displaying the data
     
  3. humanMusic

    humanMusic

    Joined:
    May 16, 2017
    Posts:
    21
    Not sure I understood. what I'm saying is that it seems Analytics.CustomEvent only receives an event name and a dict. I just want to send an event name and an int.
     
  4. Laurie-Unity

    Laurie-Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    236
    Hi humanMusic,

    As of v5.1.0 of the Analytics SDK, you can use the new generic CustomEvent Class without needing to create a Dictionary.


    Code (CSharp):
    1. CustomEvent myEvent = new CustomEvent("MyEvent")
    2. {
    3.     { "fabulousString", "woah!" },
    4.     { "peculiarBool", true },
    5.     { "sparklingInt", 1337 },
    6.     { "spectacularFloat", 313.37f }
    7. };
    8. AnalyticsService.Instance.RecordEvent(myEvent);
    Check out the Analytics Samples that can be downloaded from the Package Manager for more examples of Analytics use cases.