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

Live testing Analytics integration

Discussion in 'Unity Analytics' started by MeekBits, Apr 26, 2020.

  1. MeekBits

    MeekBits

    Joined:
    Feb 25, 2020
    Posts:
    6
    Is it still possible to live test integration of Analytics?

    I used to think that Funnel Events Validator (Operate=>Analytics=>Funnel Analyzer=>Create Funnel) was showing this, but now I can't get it to show anything. I tried in the editor with AnalyticsSettings.testMode=true and sending Custom TestEvent, for which the AnalyticsResult was Ok.
    Capturing traffic (Fiddler) doesn't show anything meaningful.

    The next date I saw expected events in Data explorer, but only for the editor.
    Analytics from an Android device are not present, even though AnalyticsResult is always Ok. This is the main reason that drives this question.
     
  2. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    Could you provide the network traffic log? You can use a network traffic analyzer, such as Charles Proxy to confirm if you are sending Analytics Events:
    https://www.charlesproxy.com/
    https://support.unity3d.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity
     
  3. MeekBits

    MeekBits

    Joined:
    Feb 25, 2020
    Posts:
    6
    I set up Charles and recorded the traffic while starting the game 3 times.
    Each time I send a couple of analytic events. The only Unity connections made are the ones for Unity Ads (session in the attachment).



    Additionally I output this diagnostic info each time:

    [Log 07:02:30.631] Analytics.enabled - True
    [Log 07:02:30.633] Analytics.deviceStatsEnabled - True
    [Log 07:02:30.634] Analytics.initializeOnStartup - False
    [Log 07:02:30.635] Analytics.limitUserTracking - False
    [Log 07:02:30.637] Analytics.playerOptedOut - False
    [Log 07:02:30.638] PerformanceReporting.enabled - True
    [Log 07:02:30.639] Test call (TestEvent) result: Ok



    If Analytics.initializeOnStartup - False catches your eye, it is made such way to give the user a choice to allow Analytics. If the user agreed, the following code enables Analytics:

    Analytics.ResumeInitialization();
    Analytics.enabled = true;
    Analytics.deviceStatsEnabled = true;
    PerformanceReporting.enabled = true;
     

    Attached Files:

  4. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    It seems that Analytics was not successfully enabled. Did you enable Analytics on the services window? What version of the Unity editor are you using?
     
  5. MeekBits

    MeekBits

    Joined:
    Feb 25, 2020
    Posts:
    6
    I did enable Analytics on the services window (they are sent from the Editor, but not from the Android build).
    The editor version is 2019.3.8f1
    The version of the "Analytics Library" package is 3.3.5

    A relevant section from UnityConnectSettings.asset is as follows:

    UnityAnalyticsSettings:
    m_Enabled: 1
    m_TestMode: 0
    m_InitializeOnStartup: 0


    In the build script, I set the following settings:
    UnityEditor.Analytics.AnalyticsSettings.enabled = true;
    UnityEditor.Analytics.AnalyticsSettings.initializeOnStartup = false;
    UnityEditor.Analytics.AnalyticsSettings.testMode = false;
    UnityEditor.Analytics.PerformanceReportingSettings.enabled = false;
     
  6. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    This script will disable Analytics on runtime. Could you comment on it first to see if Analytics is normal?
    Code (CSharp):
    1. UnityEditor.Analytics.AnalyticsSettings.enabled = true;
    2. UnityEditor.Analytics.AnalyticsSettings.initializeOnStartup = false;
    3. UnityEditor.Analytics.AnalyticsSettings.testMode = false;
    4. UnityEditor.Analytics.PerformanceReportingSettings.enabled = false;
     
  7. MeekBits

    MeekBits

    Joined:
    Feb 25, 2020
    Posts:
    6
    Thank you. I needed to take some time to make sure events are present in the Data Explorer.

    I made the change you wrote about and one more.

    Before, I had the Analytics disabled in a static method (I wanted to be extra sure they are not enabled in an opt-in flow):

    Code (CSharp):
    1.     [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
    2.     private static void Init()
    3.     {
    4.             Analytics.enabled = false;
    5.             Analytics.initializeOnStartup = false;
    6.             Analytics.deviceStatsEnabled = false;
    7.             PerformanceReporting.enabled = false;
    8.     }
    But it turned out that I was not able to enable them.
    That's not actually needed and after getting rid of the code mentioned above, Analytics work again.

     
    Last edited: Apr 28, 2020
    SamOYUnity3D likes this.