Add Facebook Analytics in Buildbox – Android

Buildbox is one of the fastest growing game engine. With Buildbox creating games is simple and requires no programming skills. One of the drawback of such game engines is that you cant extend or add custom logic in the game logic.

Analytics plays a major role in improving the game play and helps in drawing more players. It also helps in determining many important parameters like retention, ARPU, LTV. I will not go into details of each of these terms.

Let me get to the point and see how we can add Facebook analytics in a Buildbox exported android game. The guide assumes that you have basic understanding of exporting buildbox games. There will be few modifications that are required to add analytics.

  • Open exported project in Android Studio and open build.gradle file. Add this single line inside the dependencies tag and sync project.
compile '
  • Open AndroidManifest.xml file and add application id meta tag inside application.
<meta-data android:name="com.facebook.sdk.ApplicationId" 
<activity android:name="com.facebook.FacebookActivity" 
    android:configChanges= "keyboard|keyboardHidden|screenLayout|screenSize|orientation" 
    android:label="@string/app_name" /> 
<activity android:name="com.facebook.CustomTabActivity" 
        <action android:name="android.intent.action.VIEW" /> 
        <category android:name="android.intent.category.DEFAULT" /> 
        <category android:name="android.intent.category.BROWSABLE" /> 
        <data android:scheme="@string/fb_login_protocol_scheme" /> 


  • Add facebook app id in strings.xml file. Replace the string with your facebook app id
<string name="facebook_app_id">1234567890</string>

<string name="fb_login_protocol_scheme">fb1234567890</string>


Add Facebook Analytics Events

You can log game screen enter and exit app events by updating few lines of exported code.

  • Open file. It is situated in com/secrethq/utils folder.
  • Search screenOnEnter and screenOnExit function to add your app events.

Code Example for tracking screen enter and screen exit events.

public static void screenOnEnter(String name){
	Log.e(TAG, "PTServicesBridge  -- screenOnEnter:" + name);
public static void screenOnExit(String name){		 
        Log.e(TAG, "PTServicesBridge  -- screenOnExit");

Compile and run the code and you will see app events in analytics dashboard. Similarly you can add any analytics like game analytics, appsflyer or firebase analytics in ios buildbox game code. 

Leave a Reply