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.

Question Custom event array parameter

Discussion in 'Unity Analytics' started by tamper2, Feb 2, 2023.

  1. tamper2

    tamper2

    Joined:
    Dec 30, 2012
    Posts:
    9
    Hi,
    After searching through the forums and documentation I still could not find an answer, so I'm trying my luck!

    I have a custom event that I send when a player has finished a level, and I want to add the status of all the challenges that he's completed, which are stored as an array in-game.
    For example, the player has won and completed challenge 1,3,5 but not 2 and 4. So I want to send this data along with the game over event - to be able to view which challenges are most likely completed by the game's completion.

    Is this possible in any way that does not involve creating a bunch of custom parameters (challenge1, challenge2, challenge3, etc...) for sending this data?
    So far I've created a new custom parameter for each piece of data that I'm sending, and attached that manually to each event that uses that data (for example, levelWin or levelLose both send most parameters). But doing that manually with the arrays would be tedious and not very future-proof...

    Perhaps using nested JSON object in a string parameter? But then I'm not sure how I would query that in the SQL Data Explorer... :)

    The only other way I thought of would be sending many custom events - one for each challenge - when the game is over, but thought that may be overkill...?

    Would appreciate any help or pointers in the right direction, thank you!
     
  2. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
    Why would you not just send the array as a parameter?
    Or this could also be a good place to use struct(s).
     
  3. tamper2

    tamper2

    Joined:
    Dec 30, 2012
    Posts:
    9
    How can I send an array or a struct through Unity Analytics?
    As far as I saw the only parameter types are int, float, bool or string...
     
  4. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
    "Note that events must be one of the following types: string, int, long, float, double, or bool."
    Yeah nvm, my bad.
    I guess a json-string would be your best bet here.
     
  5. RandolfKlemola

    RandolfKlemola

    Unity Technologies

    Joined:
    May 1, 2020
    Posts:
    130
    Hi tamper2,

    It might be best to do as you described and record events per challenge. Are your challenges like levels or missions? Or are these individual challenges within a level or mission? Having a challengeCompleted event with a challengeName parameter would do the trick. If your game has hundreds and hundreds of challenges per player that might not be the most productive solution, of course.

    Let me know what you think!

    Randy
     
  6. tamper2

    tamper2

    Joined:
    Dec 30, 2012
    Posts:
    9
    Hi Randy,
    Thanks for the recommendation.
    I only have a few challenges per level, and for now that's the solution I went with - sending the event whenever the challenge is completed.
    Hopefully that'll be good enough, thanks!
     
    RandolfKlemola likes this.