Facebook App events are not logged, only launch/installs are logged

I am working with Facebook sdk for Ionic2 and I need to log app events on Facebook Analytics. I am following this https://ionicframework.com/docs/native/facebook/. But the problem is, I can’t find the exact documentation for the Event names I want to log. For example, each time I open my app, a launch event is being logged in FB analytics. But even if I put Facebook.logEvent("EVENT_NAME_ADDED_TO_CART"); no such event is being logged in FB analytics. I have also tried only Facebook.logEvent("ADDED_TO_CART"); But no luck ! And furthermore, I also need to know the exact syntax for passing parameters with the event names, plus how to put customize events ! Any suggestion ?

You will find them here: https://github.com/jeduan/cordova-plugin-facebook4#events

The events have nothing to do with the native wrapper for this plugin.

@LoLStats, How to use this in Ionic 2/ angular 2 ? I mean I used it before but facebookConnectPlugin was not being resolved. There is no documentation on where to inject it. Have anyone worked with this ?

https://ionicframework.com/docs/native/facebook/ is a wrapper for this plugin https://github.com/jeduan/cordova-plugin-facebook4#events so you just use https://ionicframework.com/docs/native/facebook/#logEvent.

@Sujan12, yes I am using this same thing docs/native/facebook/#logEvent. But I am stuck at the point of event names. Android doc for event names shows one way logger.logEvent(AppEventsConstants.EVENT_NAME_VIEWED_CONTENT) and for Javascript , event names are put in another way i.e. FB.AppEvents.logEvent(FB.AppEvents.EventNames.VIEWED_CONTENT).
I am using Ionic plugin so my syntax is, Facebook.logEvent() and i want to know here, how to put the event name inside this method? I have tried both "EVENT_NAME_VIEWED_CONTENT" and simply VIEWED_CONTENT . But i suspect , this is not even being called !! :confused:

The only thing that worked is the JS-sdk, but I can’t call it from within my Ionic2 code (from typescript!) There is no step by step documentation for Ionic 2 facebook app events logging !

Ok, having looked at the docs of the Cordova plugin I now understand your confusion. There are only these Constants from the Facebook SDKs documented, but not the actual string values that should be sent in via the Ionic Native plugin.

I think you are looking for this: https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/main/java/com/facebook/appevents/AppEventsConstants.java

Or more exactly:

Let me know if this works, then we can go update the Cordova plugin and Ionic Native plugin docs.

1 Like

I will add them later


Same list for Unity: https://github.com/facebook/facebook-sdk-for-unity/blob/master/Facebook.Unity/AppEventName.cs
And iOS: https://github.com/facebook/facebook-ios-sdk/blob/f257b9aa07725f2acf3a165ae3e47f62a5745ecd/FBSDKCoreKit/FBSDKCoreKit/FBSDKAppEvents.m

(Posting this because there are probably inconsistencies - I would prefer having a proper link on the developer.facebook site… but I can’t find one for now)

1 Like

Thanks a lot !!! I just compiled and logged my first content view event with param! But would it help if I try to put customized event names ? Thanks again :slight_smile:

1 Like

You should be able to create your own Events like

MY_EVENT: 'fb_my_event'

1 Like

Or just this.fb.logEvent('fb_my_event');, right?

1 Like

Of course :slight_smile:

1 Like

i regret to bother you again , since the events are being logged from my development apk, not from the signed one :confused: I have added release key hash (https://developers.facebook.com/docs/android/getting-started#release-key-hash) in the app dashboard settings page too, made the app public in facebook settings. But I seriously can’t understand what might be the reason !

I want to add that, my app is not released in the playstore yet , I am only testing the signed apk before final release.