简体   繁体   English

为什么 Facebook 的 Unity SDK 没有将事件记录到分析中?

[英]Why is Facebook's Unity SDK Not Logging Events To Analytics?

For some reason, I am unable to get the FB.LogAppEvent to work inside an android application built with Unity.出于某种原因,我无法让FB.LogAppEvent在使用 Unity 构建的 android 应用程序中工作。

Based on the documentation I've read, the code below should work.根据我读过的文档,下面的代码应该可以工作。 But it's not producing results inside the analytics dashboard.但它不会在分析仪表板内产生结果。 You'll notice a method that produces an Android toast that confirms activation.您会注意到一种生成确认激活的 Android Toast 的方法。 This toast does appear on application start.此 Toast 确实出现在应用程序启动时。 I've tried multiple event types, including custom types from code generated by Facebook's event generator in the event documentation.我尝试了多种事件类型,包括事件文档中 Facebook 事件生成器生成的代码中的自定义类型。

https://developers.facebook.com/docs/app-events/unity https://developers.facebook.com/docs/unity/reference/current/FB.LogAppEvent/ https://developers.facebook.com/docs/app-events/unity https://developers.facebook.com/docs/unity/reference/current/FB.LogAppEvent/

private void Awake()
{
    if (!FB.IsInitialized)
        FB.Init( () => { OnInit(); } );

    else
        ActivateFacebook();
}

private void OnInit()
{
    if (FB.IsInitialized)
        ActivateFacebook();

    else
        ShowAndroidToastMessage("Failed To Initialize Facebook..");
}

private void ActivateFacebook()
{
    FB.ActivateApp();

    ShowAndroidToastMessage("Facebook Activated..");

    FB.LogAppEvent(AppEventName.ActivatedApp);
}

I suppose the problem is in the way you send event我想问题在于你发送事件的方式

There are two methods for that:有两种方法:

  1. LogAppEvent(string logEventName); LogAppEvent(string logEventName);
  2. LogAppEvent(string logEventName, float valueToSum, Dictionary parameters = null); LogAppEvent(string logEventName, float valueToSum, Dictionary parameters = null);

You are using second method with "valueToSum" = 0, and that indicates there is nothing to sum, so your event probably gets skipped at some point.您正在使用“valueToSum”= 0 的第二种方法,这表明没有什么可求和的,因此您的事件可能会在某些时候被跳过。 You should use the first method FB.LogAppEvent(AppEventName.ActivatedApp);您应该使用第一种方法 FB.LogAppEvent(AppEventName.ActivatedApp);

Also make sure your analytics is enabled in dashboard.还要确保在仪表板中启用了您的分析。 Do you see any built in analytic events?您是否看到任何内置的分析事件? Feg.费。 App Launches and other Standard events should be visible out of the box.应用启动和其他标准事件应该是开箱即用的。 在此处输入图片说明

For me, LogAppEvent(...) successfully works with the Facebook Events Tracker and Analytics when you do a development build with Unity.对我来说,当您使用 Unity 进行开发构建时,LogAppEvent(...) 可以成功地与 Facebook 事件跟踪器和分析一起使用。 When I switch to a release build, I then do not get any of the LogAppEvents other than the ActivateApp() notification.当我切换到发布版本时,除了 ActivateApp() 通知之外,我不会收到任何 LogAppEvents。

Will update my answer when I get it working with a release build.当我使用发布版本时会更新我的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM