Analytics - Custom events not getting displayed on Event Browser

Hi everyone,

I’m having some trouble with recording a custom event using Unity Analytics, and I’m hoping someone can help me out. I’ve followed the documentation and set up my code to record a custom event called *user_jumped*, but nothing appears on the dashboards in either the production or development environments. Here’s the code I’m using:

using Unity.Services.Analytics;
using Unity.Services.Core;
using Unity.Services.Core.Environments;
using UnityEngine;
using System;

public class GameAnalytics : Singleton<GameAnalytics> {
    public enum EnvironmentType {
        Development,
        Production
    }

    [SerializeField]
    private EnvironmentType _environment = EnvironmentType.Production;

    protected override void Awake () {
        base.Awake ();
    }

    async void Start () {
        try {
            // Specify the environment options
            var options = new InitializationOptions();
            options.SetEnvironmentName(_environment.ToString().ToLower());
            await UnityServices.InitializeAsync(options);
            Debug.Log("Analytics initialized successfully.");
        } catch (Exception ex) {
            Debug.LogError($"Failed to initialize analytics: {ex.Message}");
        }
    }

    void Update () { }

    public void TrackUserJumpedEvent (float jumpDistance) {
        if (UnityServices.State != ServicesInitializationState.Initialized) {
            Debug.LogError("Analytics is not initialized. Event not sent.");
            return;
        }

        try {
            CustomEvent e = new CustomEvent("user_jumped");
            e.Add("jump_distance", jumpDistance);
            AnalyticsService.Instance.RecordEvent(e);
            AnalyticsService.Instance.Flush();
            Debug.Log("Analytics event 'user_jumped' sent successfully.");
        } catch (Exception ex) {
            Debug.LogError($"Failed to send analytics event: {ex.Message}");
        }
    }
}

What’s happening:

  1. The analytics service initializes without any errors, and I see the debug message “Analytics initialized successfully.”
  2. When recording the user_jumped event, the debug message “Analytics event ‘user_jumped’ sent successfully.” is logged.
  3. The event does not show up on the analytics dashboards in either production or development environments.
  4. I’ve verified that the environment names are correctly set.

Am I missing something? Are there additional steps or configurations needed to ensure that custom events are properly recorded and displayed on the dashboards?

Any help or advice would be greatly appreciated!

Thanks!

for those having the same problem, the solution was pretty simple. You need to add the following line after the initialisation:

AnalyticsService.Instance.StartDataCollection();

I hope it helps somebody, because the documentation it’s quite broken/deprecated

3 Likes

Hi @hotlabs1 ,

Thanks for bringing this up! It was a consistent issue for a little while. Can you double check the latest documentation and see if you still find it broken/deprecated? This specific part of the documentation was hidden in SDK Setup, which is now part of the Get Started section.

As a super important part of the integration, I agree this should be upfront. Whether you do this or don’t do this, I appreciate you!