简体   繁体   中英

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.

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. This toast does appear on application start. I've tried multiple event types, including custom types from code generated by Facebook's event generator in the event documentation.

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);
  2. 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. You should use the first method 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. When I switch to a release build, I then do not get any of the LogAppEvents other than the ActivateApp() notification.

Will update my answer when I get it working with a release build.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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