Search Unity

Question Custom parameters

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

  1. mariabrito17

    mariabrito17

    Joined:
    Feb 23, 2021
    Posts:
    10
    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

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    282
    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);
    12.  
    13.         // You can call Events.Flush() to send the event immediately
    14.         AnalyticsService.Instance.Flush();
    15.     }
    16.  
    Hope this helps you out.
     
    Julian-Unity3D likes this.