cordova-plugin-facebook4 don't send logEvent

776 views Asked by At

I'm using ionic with plugin cordova-plugin-facebook4. When I try to use logEvent() I didn't receive any error and also didn't get the information to my Facebook analytics.

I used logEvent() in the following way:

facebookConnectPlugin.logEvent('my event name', {}, 1);
2

There are 2 answers

0
Rohin Mohanadas On

Using arbitrary Strings as Event names are allowed. For e.g.

Facebook.logEvent('InvoicePage', {}, 1).then(function (value) {console.log('fulfilled logevent'); }, function (reason) {console.log('failed logevent'); });;

where Facebook is referred from :

import {Facebook} from "ionic-native";

One reason for the analytics not showing up is if you had to change the APP_ID or APP_NAME for some reason. To fix this, remove and install "cordova-plugin-facebook4" using

ionic plugin remove cordova-plugin-facebook4 --save

and reinstall using with the new values

ionic plugin add cordova-plugin-facebook4 --variable APP_ID="new_app_id" --variable APP_NAME="myApplication"
0
Grant Park On

According to their documentation, you can't log arbitrary strings as event names. You have to use their supported event constants, e.g. FBSDKAppEventNameActivatedApp, FBSDKAppEventNameAddedPaymentInfo, FBSDKAppEventNameCompletedRegistration, etc.

I assume you tried to log a random string that wasn't in their table of constants, which is why it didn't show up on your analytics dashboard.

https://developers.facebook.com/docs/app-events/ios