skip to Main Content

I am trying to implement FB’s AppEventLogger in an APP in order to track user behavior and purchases.
The “APP” is hybrid – it is cordova based. It is loaded from InAppBrowser and is actually a javascript/PHP website.
I am using the Javascript API for the AppEventLogger like so:

var $fCity = $('#fromCity').val();
var $tCity = $('#toCity').val();
var params = { };
params[FB.AppEvents.ParameterNames.CONTENT_TYPE] = $fCity + ' - ' + $tCity;
FB.AppEvents.logEvent(
    FB.AppEvents.EventNames.SEARCHED,
    null, 
    params
);

Which sends the following request to facebook:

request made from the app inside the inappbrowser

When this request is sent from the app to facebook, nothing happens. The event is not logged.
However, when the same link/request is opened/made from a regular browser, even by just visiting the InAppBrowser source page trough the browser, the event is logged.
Also, I have the Facebook SDK installed as a Cordova plugin and send events via the plugin (as an app – when it starts and ends) – then it also works. But since the app is inside the inappbrowser, I can not use that plugin for the other pages.

I have checked the whitelist plugin and connections are allowed to facebook.com. You can even see that we get a 200 response and the gif headers from Facebook’s server.

Why does Facebook’s AppEventBrowser not log events sent from the InAppBrowser plugin?

2

Answers


  1. Chosen as BEST ANSWER

    I could not find a way to get around the limitation. In the end I used the Cordova plugin for facebook's SDK to do what I want to.


  2. Few things to check

    1. First load the debug version of JS SDK
    (js.src = “//connect.facebook.net/en_US/sdk/debug.js”;)
    and see the logs.

    2. inAppBrowser can’t access Cordova APIs so just in case any part of your code/library is trying to access a Cordova API so that may generate an issue, and maybe a request argument is missing which Facebook event requires by default to log (e.g. it logs android version etc.). You can compare the arguments with a successful request.

    For hybrid apps the recommended way by Facebook is to use the event API
    https://developers.facebook.com/docs/marketing-api/app-event-api/v2.8

    For other platforms that utilize web-view within a native app, one option would be to utilize the App Events API to pass events from your server to the Facebook servers.

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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search