Search Unity

Will Crash If Custom Event Not Created?

Discussion in 'Unity Analytics' started by rikkir, Jun 6, 2017.

  1. rikkir

    rikkir

    Joined:
    Feb 11, 2015
    Posts:
    16
    If I have created a method, for a custom event, such as...
    Code (csharp):
    1.  
    2.     public static void tutorialOpened(){
    3.         Analytics.CustomEvent ("tutorialOpened");
    4.     }
    5.  
    But in Analytics, I have not actually set up this Custom Event, will any type of crash occur?
     
  2. ap-unity

    ap-unity

    Unity Technologies

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

    As long as you have Analytics enabled in the Services window, there is no setup required to use Custom Events. All you need to do is send them.

    Also, I would suggest you take a look at our new Standard Events. They provide some common uses for Custom Events, such as starting a tutorial.
    https://blogs.unity3d.com/2017/05/12/introducing-standard-events/
     
  3. rikkir

    rikkir

    Joined:
    Feb 11, 2015
    Posts:
    16
    Oh wow.
    So I don't have to do any type of set up, with in the account, in regards to Custom Events???
    How cool.


    Just to be clear I am using two forms of Custom Events, one a count, where I send no value. I simply expect Unity Analytics to tick up, at each send.
    Code (csharp):
    1.  
    2.     public static void sharedVia_FB(){
    3.         Analytics.CustomEvent ("sharedVia_FB");///!
    4.     }

    And the other, I want to send a float, that can be looked at to see comparable time length, played.
    Code (csharp):
    1.  
    2.     void OnApplicationQuit()
    3.     {
    4.         time_ofPlay = Time.time - time_atSplash;
    5.         Analytics.CustomEvent("time_ofPlay", new Dictionary<string, object>{
    6.             {"value", time_ofPlay}
    7.         });
    8.     }
    9.  

    So, once I set this up in code, I am good to go?
     
  4. ap-unity

    ap-unity

    Unity Technologies

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

    Your first method (sharedVia_FB) should work fine.

    For the second one, Analytics events are not consistently sent from OnApplicationQuit. I would encourage you to use OnApplicationPause instead, since that is more reliable.
     
    rikkir likes this.
  5. rikkir

    rikkir

    Joined:
    Feb 11, 2015
    Posts:
    16

    Right. I had put it there, since the game may reopen, but I am sure pause will do now that I think of it.
    Thank you.