Search Unity

very beginner code for analytics

Discussion in 'Unity Analytics' started by dougbello, Oct 14, 2015.

  1. dougbello

    dougbello

    Joined:
    Apr 9, 2015
    Posts:
    15
    Hello guys,

    I'm really new at unity and C# I'm finishing my game with playmaker but I would love to have some analytics feedback.

    I already implement unity analytics to my game and its working on its basic function. (using latest 5.2.1f1)

    But I need a custom event just to know when a player reaches the level and how many crystals he has at this moment.

    I'm thinking in a code like this:

    using UnityEngine;
    using System.Collections;
    using UnityEngine.Analytics;
    using System.Collections.Generic;

    public class analytics_try : MonoBehaviour {

    public int levelReach;
    private int totalCrystals;



    void OnTriggerEnter(Collider other) {


    Analytics.CustomEvent("level", new Dictionary<string, object> {

    { "level", levelReach },
    { "crystals", totalCrystals },

    });


    }

    }


    I know its a sh*** wrong code, but I'm hoping someone can help me here.

    Thanks a lot.
    Doug.
     
  2. mpinol

    mpinol

    Joined:
    Jul 29, 2015
    Posts:
    317
    Hi @dougbello,

    I would remove the comma after 'totalCystals },' and make sure that you assign values to levelReach and totalCrystals before sending the event and you are all set!

    For a good way to view this data I would suggest using a Funnel. You can create each step of the Funnel where the parameter 'levelReach' corresponds to the level value and then in the Funnel Analyzer page you can select 'Parameters Overview' from the Drilldown Type menu to see the average number of totalCrystals each user collected on a particular level. You can read more about funnels here, https://unity3d.com/learn/tutorials/analytics/intro-to-funnels
     
  3. dougbello

    dougbello

    Joined:
    Apr 9, 2015
    Posts:
    15
    Thank you @mpinol !

    Even with my ZERO C# knowledge it is working!!!!

    Thanks again.
    Doug
     
    mpinol likes this.