Search Unity

Can get specific data, like every customerID? or does it only count/sum/average

Discussion in 'Unity Analytics' started by radglade, Oct 17, 2016.

  1. radglade

    radglade

    Joined:
    Feb 17, 2014
    Posts:
    19
    Hi,

    eg.

    public void SuccessfulLogIn(int CustomerId)
    {
    UnityEngine.Analytics.Analytics.CustomEvent("SuccessfulLogIn", new Dictionary<string, object>
    {
    { "CustomerId", CustomerId}

    });
    Debug.Log("SuccessfulLogIn:" + CustomerId);

    }

    Can I get a list of every customerId? I only seem to be able to get the count/sum/average. I'm assuming you can only get those values to save space.
     
  2. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    Hi @radglade,

    Thanks for asking! We discourage you from collecting unique data on individual users, which (under some circumstances) might violate our terms of service. Also, this is usually difficult to do given that collecting any unique ID will quickly expend all your Analysis Points.

    That said, if you have a Pro account, you can use Raw Data Export to look at Device IDs...this is probably sufficient to expose the behavior you're after without actually exposing anything personally identifiable. I suppose the better question, though, is "what are you trying to learn about your users"? Perhaps if I understood that, I could suggest a helpful solution that didn't require you to record unique IDs every time.
     
    radglade and ap-unity like this.
  3. radglade

    radglade

    Joined:
    Feb 17, 2014
    Posts:
    19
    Thanks for your help,
    It makes sense now.

    Can you do empty Custom events? like this
    UnityEngine.Analytics.Analytics.CustomEvent("SuccessfulLogIn", new Dictionary<string, object>
    {
    });

    Because this will always mean the user has logged in successfully, no need to put a bool in there.
     
  4. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    You should just omit the Dictionary altogether. That's a legal signature for Custom Event (note, though, that this wasn't always the case in some older versions of Unity...so might depend on the version you're using).
     
    radglade and ap-unity like this.
  5. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @radglade,

    As Marc said, the format changed a bit between 5.3 and 5.4.

    An empty dictionary does work in both 5.3 and 5.4:
    Analytics.CustomEvent("test-event", new Dictionary<string, object> { });

    Sending null as the second parameter only works up to 5.3.6 and 5.4.1*
    Analytics.CustomEvent("test-event", null); //In 5.4.0, this raises null reference exception

    Just sending the event name only works in 5.4+:
    Analytics.CustomEvent("test-event"); //This raises error in 5.3

    However, it may be worth it to send the bool if you will ever create custom segments based on this event. For example, if you want to create a segment for users that failed login on Android, that wouldn't be possible if you just send the event name. If you don't plan on creating segments with this event, then I would probably just send the event name, as Marc suggested (assuming you're on 5.4).

    Edit: Small correction. Having null as the second parameter did raise an error in 5.4.0, but this was corrected in 5.4.1.
     
    Last edited: Oct 22, 2016
    radglade likes this.
  6. berzerk

    berzerk

    Joined:
    Dec 23, 2014
    Posts:
    18
    Hello @ap-unity

    Following up on the OP question, since it is not 100% clear to me. I have a custom event that records the ID of the character selected in the game by each user. I want to generate statistics on character selection popularity, but the reports don't seem to allow me to do that - which is a very basic need, IMHO. Am I missing anything? Or is it just available to PRO customers via raw data? Thanks.
     
  7. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    Hello @berzerk

    If the character ID is sent as a number, then we would only provide count, sum or average.

    However, if you send that data as a string, then we will count each value sent. Any value that starts with a number is cast to a number. So to send data as a string, you would have to prepend a string to it. For example:

    Code (CSharp):
    1.  
    2. Analytics.CustomEvent("character", new Dictionary<string, object> {
    3.     {"character_id", "character_" + characterID }
    4. });
    5.  
    Then in the dashboard, you would be given a count of each character ID that is sent.

    You can find some more best practices in this video:
     
    berzerk likes this.
  8. berzerk

    berzerk

    Joined:
    Dec 23, 2014
    Posts:
    18
    @ap-unity , thanks for the answer. It will certainly solve the issue!


     
    ap-unity likes this.