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

Question Can't receive custom events. Standard events work fine.

Discussion in 'Unity Analytics' started by chengchonz, Aug 17, 2022.

  1. chengchonz

    chengchonz

    Joined:
    Oct 22, 2017
    Posts:
    6
    I've searched a lot and tested many times, but I still don't see my events in the dashboard. Really need some help. I've been waiting for the events to come for 4 hours.

    This is the code I'm using. The debugs do show in console. I've put UNITY_ANALYTICS_EVENT_LOGS in define symbols and it seems the events were sent successfully. Also I've defined the event and the parameter in dashboard. I use 2022.1.10f1 unity and Analytics package(not Analytics library).

    Code (CSharp):
    1. private async UniTask Start() {
    2.         try {
    3.             await UnityServices.InitializeAsync();
    4.             List<string> consentIdentifiers = await AnalyticsService.Instance.CheckForRequiredConsents();
    5.             Debug.Log("init");
    6.         } catch (ConsentCheckException e) {
    7.             Debug.Log("error");
    8.             // Something went wrong when checking the GeoIP, check the e.Reason and handle appropriately.
    9.         }
    10.  
    11.         await UniTask.Delay(2000);
    12.  
    13.         //send
    14.         Dictionary<string, object> parameters = new Dictionary<string, object>()
    15. {
    16.     { "test", true },
    17. };
    18.  
    19.         // The ‘myEvent’ event will get queued up and sent every minute
    20.         AnalyticsService.Instance.CustomData("customTestEvent", parameters);
    21.  
    22.         // Optional - You can call Events.Flush() to send the event immediately
    23.         AnalyticsService.Instance.Flush();
    24.  
    25.         Debug.Log("sended");
    26.     }
    My project ID : 14bf7ff5-3ed7-4786-9394-47fd5a207973
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @chengchonz Interesting, I'm not seeing the events either in your dashboard either and your code looks correct. As a quick test, can you move the event code out of async Start and into a separate button click, after initialization?
     
  3. chengchonz

    chengchonz

    Joined:
    Oct 22, 2017
    Posts:
    6
    Thanks for the reply. Here is the new code and the output. Also I use 4.0.1 Analytics package.

    Code (CSharp):
    1.     private async void Start() {
    2.         try {
    3.             await UnityServices.InitializeAsync();
    4.             List<string> consentIdentifiers = await AnalyticsService.Instance.CheckForRequiredConsents();
    5.             Debug.Log("init");
    6.         } catch (ConsentCheckException e) {
    7.             Debug.Log("error");
    8.             // Something went wrong when checking the GeoIP, check the e.Reason and handle appropriately.
    9.         }
    10.     }
    11.  
    12.     public void OnButtonClick() {
    13.         //send
    14.         Dictionary<string, object> parameters = new Dictionary<string, object>()
    15. {
    16.     { "test", true },
    17. };
    18.  
    19.         // The ‘myEvent’ event will get queued up and sent every minute
    20.         AnalyticsService.Instance.CustomData("customTestEvent", parameters);
    21.  
    22.         // Optional - You can call Events.Flush() to send the event immediately
    23.         AnalyticsService.Instance.Flush();
    24.  
    25.         Debug.Log("sended");
    26.     }
     
  4. chengchonz

    chengchonz

    Joined:
    Oct 22, 2017
    Posts:
    6
    Okay I solved it. I managed to clear the buffer and the disk cache. I can see the events now.
     
  5. seidensj

    seidensj

    Joined:
    Sep 10, 2014
    Posts:
    11
    Hi, would you be able to detail how you cleared the buffer and disk cache? I'm having the same problem with Custom Events not coming through. Standard events are fine. All my custom events are correctly named and enabled in the dashboard.