Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    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.

Question Custom parameters

Discussion in 'Unity Analytics' started by mariabrito17, Sep 19, 2022.

  1. mariabrito17


    Feb 23, 2021
    We have some custom parameters defined on the project that are giving trouble with parsing events.

    On the code, numbers are sent as strings, but the parameters are defined as either Integer or Float on Event Manager. The project is receiving the events but they are deemed as Invalid, because we are getting some issues, such as: "Number type expected, but not found, for field XXXXX"

    Do these parameters that are numbers but sent as string need to be defined as strings on Event Manager?
  2. SebT_Unity


    Unity Technologies

    Jun 21, 2021
    Hi Mariabrito17

    Thanks for posting on the forums.

    Could you share the code for recording of the event? In theory you should be able to simply convert your number .ToString() In the appropriate locations

    If your parameter is a string in the event manager then you should be sending in a string.
    If your parameter is a int in the event manager then you should be sending in an int.

    Simple Example:
    Code (CSharp):
    1.   private void HandleCustomEventNumber()
    2.     {
    3.         int myLevel = 1337;
    4.         //Handle Custom event
    5.         Dictionary<string, object> parameters = new Dictionary<string, object>()
    6.         {
    7.             { "levelName", myLevel.ToString() }
    8.         };
    9.         // The ‘myEvent’ event will get queued up and sent every minute
    10.         //Events.CustomData("level", parameters);
    11.         AnalyticsService.Instance.CustomData("level", parameters);
    13.         // You can call Events.Flush() to send the event immediately
    14.         AnalyticsService.Instance.Flush();
    15.     }
    Hope this helps you out.
    Julian-Unity3D likes this.