Unity Custom Events Not Showing Up On Dashboard

Hello,

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:

//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.
private void ConfigDataHandler()
    {
            analytic = ConfigurationManager.instance.GetRemoteConfigData().GetSetting(
            GlobalConfigList.SCREEN_SPACE_ON_BOOL_CONFIG) as DataConfig.BoolSetting;
    }

//Then in a different method, I'm invoking the Unity Custom Analytic call.
Analytics.CustomEvent("guardRailQuitClicks", new Dictionary<string, object>
        {
            { GlobalConfigList.SCREEN_SPACE_ON_BOOL_CONFIG, analytic.value}
        });

I would really appreciate any help I could get here. I have a deadline for my job.

Thanks

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.

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?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Services.Core;
using Unity.Services.Analytics;
using Unity.Services.Core.Environments;
using Praxis.Configuration;
public class ConfigurationAnalytics : MonoBehaviour
{
    private void Start()
    {
        InitializeAnalytics();
    }

    async void InitializeAnalytics()
    {
        try
        {
            await UnityServices.InitializeAsync();
            List<string> consentIdentifiers = await AnalyticsService.Instance.CheckForRequiredConsents();

            var options = new InitializationOptions();
            options.SetEnvironmentName("production");

            await UnityServices.InitializeAsync(options);

            //for dev testing only. will remove after analytics is working
            // Send custom event
            Dictionary<string, object> guardRailParams = new Dictionary<string, object>()
            {
                { GlobalConfigList.SCREEN_SPACE_ON_BOOL_CONFIG, true }
            };

            Dictionary<string, object> fullScreenParams = new Dictionary<string, object>()
            {
                { GlobalConfigList.SCREEN_SPACE_ON_BOOL_CONFIG, true }
            };

            Dictionary<string, object> pausePlayParams = new Dictionary<string, object>()
            {
                { GlobalConfigList.SCREEN_SPACE_ON_BOOL_CONFIG, true }
            };

            AnalyticsService.Instance.CustomData("guardRailQuitClicks", guardRailParams);
            AnalyticsService.Instance.CustomData("fullScreenClicks", fullScreenParams);
            AnalyticsService.Instance.CustomData("guardRailPausePlay", pausePlayParams);

            // Optional - You can call Events.Flush() to send the event immediately
            AnalyticsService.Instance.Flush();

            Debug.Log("MADE IT");
        }
        catch (ConsentCheckException e)
        {
            // Something went wrong when checking the GeoIP, check the e.Reason and handle appropriately.
            Debug.LogError("error with analytic consent");
        }
    }
}
2 Likes

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?

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