Unity analytics is not collecting any data

Hello, I have a project that used the legacy analytics. In February 1, 2024 Unity stopped support.
So, I removed old stuff and did the new Unity Analytics setup. But I can’t get any data in my dashboard.
I tested the game on Android and no data is showing up in the dashboard or in Event Browser.
I have the correct project selected in Project Settings → Services.
In the editor in Analytics Debug Panel all events and uploads show up correctly.

This script runs at the start of the game:

using System.Collections;
using System.Collections.Generic;
using Unity.Services.Analytics;
using Unity.Services.Core;
using UnityEngine;
using UnityEngine.Analytics;
using UnityEngine.UI;

public class UGS_Start : MonoBehaviour
{
	[SerializeField] private Text analyticsText;
	public static UGS_Start instance;
	async void Start()
	{
		if (instance == null)
		{
			instance = this;
		}
		else
		{
			Destroy(gameObject);
		}
		DontDestroyOnLoad(gameObject);

		try
		{
			await UnityServices.InitializeAsync();
			AnalyticsService.Instance.StartDataCollection();

			if (UnityServices.State == ServicesInitializationState.Initialized)
			{
				Debug.Log("Initialized Unity Analytics");
				analyticsText.text = "on";
			}
			else
			{
				Debug.Log("Not Intialized");
				analyticsText.text = "else";
			}
		}
		catch (System.Exception ex)
		{
			Debug.Log("Failed to initialize Unity Analytics {ex.Message}");
			analyticsText.text = "exce";
		}
		
		AnalyticsService.Instance.RecordEvent("test_ev");

		AnalyticsService.Instance.Flush();
	}
}

Hi @ahmetgello ,

Thanks for reaching out! Can you send me a DM with your Organization ID? I’d love to take a look. My gut would be to say it’s StartDataCollection not being called, but I see it there in your code. It could also be something to do with your project exceeding the free tier of Unity Analytics at some point, which is why I’d like to take a look at your organization first, before jumping to any conclusions.

Also, let me know which of your projects this is for, please!

Randy

1 Like

Alright, I sent you a message with the details.

I’m also having trouble with data not showing up on the dashboard.

Data was showing up on the dashboard until November 14th. However, on November 27th, I published my game on iOS and Android, and when I checked the dashboard, I noticed that the data was not showing up.

I haven’t changed any code. I haven’t changed any Unity or Analytics versions either.

  • Unity 2022.3.29f1
  • Analytics 6.0.1

“StartDataCollection” is also running.

I have the correct project selected in Project Settings → Services.

Unity Cloud → Analytics setting screen looks like the image below.

Are any other settings required?

Hi @UDN_fe680426-53b0-485c-a13d-6e ,

If you are certain that your settings and code are correct, the next thing to check is that your game client is sending Analytics Events, and they are going to the project and environment that you expect.

This guide on Using Charles Proxy with Unity and the new Editor Debug Tool for Analytics should help you determine if events are being sent and confirm where they are going.

Please check:

  1. You are getting a 204 response to Analytics uploads to https://collect.analytics.unity3d.com
  2. The Project ID in your request URL matches the one on your Unity Project Dashboard, in the Analytics Settings page, and your Analytics dashboard URLs
  3. The Environment in your request URL matches the environment you expect.

Finally, if you still can’t see any events, please submit an Analytics Support Ticket and share your Project ID, any relevant code snippets and if possible a link to a store or test build.

Thank you!

When I checked with Charles Proxy, I got a 200 response, not a 204 response. So I guessed that the request was not successful.

I tried the following steps, and the data started to appear on the dashboard. Thank you.

  1. Edit - Project Settings - Services - Unlink project

  2. Exit Unity and delete the “Library” folder.

  3. Assets - Reinport All

  4. Edit - Project Settings - Services - Link project

1 Like

Hello, I won’t get data in production. I unlinked a project on 6000.2.13f1, removed the Library, migrated to the 6000.3.3f1, and linked a project - doesn’t help.

Testing environment - 4
Production - 0 (should be 37)

Code:



    using System;
    using Unity.Services.Analytics;
    using Unity.Services.Core;
    using UnityEngine;
    using UnityEngine.UnityConsent;
     
    public class GameAnalytics : MonoBehaviour
    {
        private static bool _isInitialized;
     
        public static async void Initialize()
        {
            await UnityServices.InitializeAsync();
            _isInitialized = true;
        }
     
        #region Consent
        public static void OnAgreeButtonClicked()
        {
            var state = EndUserConsent.GetConsentState();
            state.AnalyticsIntent = ConsentStatus.Granted;
            EndUserConsent.SetConsentState(state);
        }
     
        public static void OnDisagreeButtonClicked()
        {
            var state = EndUserConsent.GetConsentState();
            state.AnalyticsIntent = ConsentStatus.Denied;
            EndUserConsent.SetConsentState(state);
        }
     
        public static void RequestDataDeletion()
        {
            OnDisagreeButtonClicked();
            AnalyticsService.Instance.RequestDataDeletion();
        }
        #endregion
     
        #region Events
        public static void MissionComplete(int missionId, MissionType missionType, GameMode gameMode, float timeTaken, float reward, int vehicleId)
        {
            if (!_isInitialized) return;
     
            CustomEvent missionCompleteEvent = new CustomEvent("mission_complete")
            {
                { "mission_Id", missionId },
                { "mission_type", (int)missionType },
                { "game_mode", (int)gameMode },
                { "time_taken", Math.Round(timeTaken, 3) },
                { "reward", reward },
                { "vehicle_Id", vehicleId }
            };
            AnalyticsService.Instance.RecordEvent(missionCompleteEvent);
            // AnalyticsService.Instance.Flush(); // dev only
        }
     
        public static void AdClicked(AdPlacement placement, float reward)
        {
            if (!_isInitialized) return;
     
            CustomEvent adClickEvent = new CustomEvent("ad_clicked")
            {
                { "placement", (int)placement },
                { "reward", reward }
            };
     
            AnalyticsService.Instance.RecordEvent(adClickEvent);
            // AnalyticsService.Instance.Flush(); // dev only
        }
     
        public static void VehiclePurchased(int vehicleId)
        {
            if (!_isInitialized) return;
     
            CustomEvent vehiclePurchasedEvent = new CustomEvent("vehicle_purchased")
            {
                { "vehicle_Id", vehicleId }
            };
            AnalyticsService.Instance.RecordEvent(vehiclePurchasedEvent);
            // AnalyticsService.Instance.Flush(); // dev only
        }
        #endregion
    }

My code is working:



Launch doesn’t work; it can be due to skipping the Tilpalti form?

Do you have Analytics enabled in dashboard?

1 Like

:waving_hand:
Yes, even the “Developer Data”.

“Data Access” isn’t set up, but it doesn’t need to be, I suppose?

I have even a “userAssignment” event in the Event Browser, but users still have 0

Unity editor in Members (link to Dashboard) has the wrong one (I changed username in the past). All other - seems ok.

The “userAssignment” events come from our Remote Config service (based on Unity support reply)

The issue isn’t gone

So idk what the issue is if you tried all the solutions,
for me I remember opening a ticket at
https://support.unity.com/hc/en-us/requests/new?ticket_form_id=360001936712&serviceName=analytics
and it was on their side, they fixed it.

1 Like