Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Proper Implementation, question

Discussion in 'Unity Analytics' started by renman3000, Oct 27, 2017.

  1. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Hi,
    I just want to be clear.

    I have Anayltics set up to run in my game.... to update the anaylictics, I am using this script, where relevant functions are called, at the appropriate time. My thinking is that with each call, the proper analytic is adjusted accordingly.

    Other than that, I do nothing. So no set up via the web sit portal, behind establishing the project.
    Am I right?

    Thank you


    Code (csharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using UnityEngine.Analytics;
    6.  
    7.  
    8.  
    9. public class Analytics_Mng : MonoBehaviour {
    10.  
    11.     public static Analytics_Mng ins;
    12.  
    13.     public static float time_atSplash;
    14.     public static float time_ofPlay;
    15.  
    16.  
    17.     // Use this for initialization
    18.     void Start () {
    19.         if (ins == null) {
    20.             ins = this;
    21.             DontDestroyOnLoad (gameObject);
    22.             time_atSplash = Time.time;
    23.             return;
    24.         }
    25.         else if(ins != null){
    26.             Destroy (gameObject);
    27.         }
    28.     }
    29.     public static void game_launched(){
    30.         //sent via splash.
    31.         Analytics.CustomEvent ("game_launched");
    32.     }
    33.     public static void gameplay_started(){
    34.         //sent via game mng.
    35.         Analytics.CustomEvent ("gameplay_started");
    36.     }
    37.     public static void game_won(){
    38.         //sent via game mng.
    39.         Analytics.CustomEvent ("game_won");
    40.     }
    41.     public static void game_lost(){
    42.         //sent via game mng.
    43.         Analytics.CustomEvent ("game_lost");
    44.     }
    45.     public static void game_tied(){
    46.         //sent via game mng.
    47.         Analytics.CustomEvent ("game_tied");
    48.     }
    49.     public static void rounds_played(){
    50.         //sent via ers mng.
    51.         Analytics.CustomEvent ("rounds_played");
    52.     }
    53.  
    54.     public static void rounds_played_vs_local(){
    55.         //sent via game mng.
    56.         Analytics.CustomEvent ("rounds_played_vs_local");
    57.     }
    58.  
    59.     public static void rounds_played_vs_cpu(){
    60.         //sent via game mng.
    61.         Analytics.CustomEvent ("rounds_played_vs_cpu");
    62.     }
    63.            
    64.     void OnApplicationPause(bool paused)
    65.     {
    66.         time_ofPlay = Time.time - time_atSplash;
    67.         print (" time of play = " + time_ofPlay.ToString());
    68.         Analytics.CustomEvent("time_ofPlay", new Dictionary<string, object>{
    69.             {"value", time_ofPlay}
    70.         });
    71.     }
    72.  
    73.  
    74.  
    75.  
    76. }
    77.  
    78.  
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Keep in mind that it can take 8-16 hours for events to start showing in the Dashboard after they are sent. The code also looks correct, but I also wanted to mention one of the new Analytics features that you might find useful. We recently introduced Standard Events, a set of curated custom events focused on player experience.

    https://blogs.unity3d.com/2017/05/12/introducing-standard-events/

    In addition to helping you determine which events you want to add to your game, Standard Events will also grant you access to some of the upcoming features we have planned for our dashboard; features that require a deeper understanding of the different critical points in your game, like a "level_start" or "tutorial_complete", etc.

    The Analytics team is also working on a series of blog posts that go into each set of events in more detail.

    https://blogs.unity3d.com/2017/06/09/standard-events-explained-part-1-onboarding/

    https://blogs.unity3d.com/2017/08/09/standard-events-explained-part-2-application-and-progression/