Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Unity Custom Events Not Showing Up On Dashboard

Discussion in 'Unity Analytics' started by mandrews_praxis, Oct 24, 2022.

  1. mandrews_praxis


    Jul 20, 2022

    I'm having a problem where my custom events don't seem to be triggering or appearing on the Unity Dashboard/Event Browser. I believe I have everything set up properly, and now I just have reached the point where I am out of answers.

    1) I have my environments properly set up. I know this because I'm also using RemoteConfig with my production environment like I'm trying to use Analytics and it works perfectly.

    2) I have Analytics turned on in my project. I know this because I am getting normal/default Analytic events in the Unity Dashboard/Event Browser.

    3) The below set up is how I'm calling the Custom Events. I believe it is according to the manual, but please correct me if I'm wrong:

    Code (CSharp):
    1. //I have a class I created name "Bool Setting" which stores a string value and a bool to go with it. That's what this code is getting.
    2. private void ConfigDataHandler()
    3.     {
    4.             analytic = ConfigurationManager.instance.GetRemoteConfigData().GetSetting(
    5.             GlobalConfigList.SCREEN_SPACE_ON_BOOL_CONFIG) as DataConfig.BoolSetting;
    6.     }
    8. //Then in a different method, I'm invoking the Unity Custom Analytic call.
    9. Analytics.CustomEvent("guardRailQuitClicks", new Dictionary<string, object>
    10.         {
    11.             { GlobalConfigList.SCREEN_SPACE_ON_BOOL_CONFIG, analytic.value}
    12.         });
    I would really appreciate any help I could get here. I have a deadline for my job.

  2. SebT_Unity


    Unity Technologies

    Jun 21, 2021
    Hi mandrews_praxis
    Thanks for posting on the forums.

    Unfortunately this snippet of code is using Legacy Analytics code.
    Could you provide the steps that lead you to that code?

    In the meantime here is the right documentation to help you get started.

    Please let me know if you have any additional questions.
  3. mandrews_praxis


    Jul 20, 2022
    Hi SebT,

    Thanks for getting back to me. I have now gone back and implemented this properly in code. But I just wanted to write a quick script to test this out before I put it everywhere. I put in the app about 30 min ago but still have not seen anything on the dashboard, though I know it can take about 48 hours sometimes. Is this code correct?

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using Unity.Services.Core;
    5. using Unity.Services.Analytics;
    6. using Unity.Services.Core.Environments;
    7. using Praxis.Configuration;
    8. public class ConfigurationAnalytics : MonoBehaviour
    9. {
    10.     private void Start()
    11.     {
    12.         InitializeAnalytics();
    13.     }
    15.     async void InitializeAnalytics()
    16.     {
    17.         try
    18.         {
    19.             await UnityServices.InitializeAsync();
    20.             List<string> consentIdentifiers = await AnalyticsService.Instance.CheckForRequiredConsents();
    22.             var options = new InitializationOptions();
    23.             options.SetEnvironmentName("production");
    25.             await UnityServices.InitializeAsync(options);
    27.             //for dev testing only. will remove after analytics is working
    28.             // Send custom event
    29.             Dictionary<string, object> guardRailParams = new Dictionary<string, object>()
    30.             {
    31.                 { GlobalConfigList.SCREEN_SPACE_ON_BOOL_CONFIG, true }
    32.             };
    34.             Dictionary<string, object> fullScreenParams = new Dictionary<string, object>()
    35.             {
    36.                 { GlobalConfigList.SCREEN_SPACE_ON_BOOL_CONFIG, true }
    37.             };
    39.             Dictionary<string, object> pausePlayParams = new Dictionary<string, object>()
    40.             {
    41.                 { GlobalConfigList.SCREEN_SPACE_ON_BOOL_CONFIG, true }
    42.             };
    44.             AnalyticsService.Instance.CustomData("guardRailQuitClicks", guardRailParams);
    45.             AnalyticsService.Instance.CustomData("fullScreenClicks", fullScreenParams);
    46.             AnalyticsService.Instance.CustomData("guardRailPausePlay", pausePlayParams);
    48.             // Optional - You can call Events.Flush() to send the event immediately
    49.             AnalyticsService.Instance.Flush();
    51.             Debug.Log("MADE IT");
    52.         }
    53.         catch (ConsentCheckException e)
    54.         {
    55.             // Something went wrong when checking the GeoIP, check the e.Reason and handle appropriately.
    56.             Debug.LogError("error with analytic consent");
    57.         }
    58.     }
    59. }
    Ohilo and SebT_Unity like this.
  4. mandrews_praxis


    Jul 20, 2022
    K, so it looks now like these are working. however, on the dashboard, they are showing up as "invalid events"

    "Incoming event contains unexpected key 'screenspaceOn' containing value true"

    These are the values I passed in when I sent them. Is this pertaining to "parameters" in the initial set up?
  5. SebT_Unity


    Unity Technologies

    Jun 21, 2021
    The code looks great!
    I don't have access to your ORGID(You can dm me if the following doesn't resolve your issue). However I suspect from the error, you may not be enabling the event?
    • On the dashboard head to ANALYTICS > EVENT MANAGER > EVENTS
    • Search the parameter you created.
    • Click on the enabled button.
    If the above is in fact enabled. Make sure that you have assigned the parameter screenSpaceOn to the following events:
    • guardRailQuitClicks
    • fullScreenClicks
    • guardRailPausePlay

    Let me know if that helps you out