Integrating Game Analytics - Android

Discussion in 'Buildbox General Discussion' started by Appossible, Oct 3, 2018.

  1. Appossible

    Appossible Avid Boxer

    Joined:
    Aug 14, 2017
    Messages:
    198
    Likes Received:
    56
    Hi boxers,
    I'm trying to integrate GA to my android game and I got a problem.
    I don't have any idea where to put this code. I don't know where the main activity is. Anyone knows how to do this? Thank you!

    • // Initialize
    • GameAnalytics.initializeWithGameKey(activity, "[game key]", "[secret key]");
    To initialize the SDK you need to call the method below, using the apps main activity, and the game key and game secret for your game.
     
  2. SpoonCrysis

    SpoonCrysis Avid Boxer

    Joined:
    Aug 10, 2018
    Messages:
    175
    Likes Received:
    26
    the Android SDK for gameAnalytics is rubbish, I have never been able to get to work in Android studio only seems to work in iOS with out issues but Android, seems to be rubbish.
     
  3. maxcar

    maxcar Boxer

    Joined:
    Sep 27, 2018
    Messages:
    23
    Likes Received:
    4
    Hi. I was able to implement GameAnalytics for an Android game and wanted to share this.
    I'm able to see active sessions on my GameAnalytics console, which is the basic setup. However, I don't know how to track specific events like buttons taps, specific worlds or ui's the users are in, which would be ideal, but I hope someone with more knowledge can help us with this.
    There's a guide published for iOS on how to implement and set up other tracking events (http://help.buildbox.com/advertising-and-sdks/game-analytics-ios). I did contact buildbox a while ago for an Android implementation but I'm still waiting for some info.

    Here are the steps for Android
    **** Check GameAnalytics guide as there may be some changes when you see this post
    https://gameanalytics.com/docs/item/android-sdk


    GameAnalytics:
    1. Create account in GameAnalytics and create a new project for your game.
    2. Get your Game key and Secret key from your settings section.

    Android:
    1. Add dependency for GameAnalytics on your build.gradle (Module: app) file:

    dependencies {
    // GameAnalytics //
    implementation 'com.gameanalytics.sdk:gameanalytics-android:3.4.2'
    }


    2. Call maven repository on your build.gradle (Project: android) file:

    allprojects {
    repositories {
    jcenter()
    maven {
    url 'http://maven.gameanalytics.com/release'
    }
    }
    }

    3. Sync your gradle files (you will see a notification prompting you to sync gradle files after changing them).

    4. Import GameAnalytics sdk and initialize it on you PTPlayer.java file (app/src/main/java/com/yourcompany/yourgame/PTPlayer.java).

    4.1 at the top of the file you will see a list of imports. Include the following line:
    import com.gameanalytics.sdk.*;

    4.2 Around line 64 you should Start GameAnalytics and include your Game key "GGG" and Secret key "SSS".
    You can also include your project build number reference.

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.hideVirtualButton();

    PTServicesBridge.initBridge(this, getString( R.string.app_id ));
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // GameAnalytics
    // Configure build version
    GameAnalytics.configureBuild("1.1.1");

    // Initialize
    GameAnalytics.initializeWithGameKey(this, "GGG", "SSS");

    }

    5. Test it with logcat on Android Studio

    You can include the following lines to see if your game is sending events. Then run your game on a device and open Logcat to check for "gameanalytics" events.

    // GameAnalytics
    // Enable log
    GameAnalytics.setEnabledInfoLog(true);
    GameAnalytics.setEnabledVerboseLog(true);


    6. Test it on GameAnalytics website.

    Run your game on a device and go to your GameAnalytics console for your project. You will see a "REaltime" tab.
    Play your game for a while and check the console. You may have to wait some minutes to see any activity.
    Alternatively you can also submit your game for an Alpha/Beta test and send it to your friends. You should be able to see some activity on your "Overview" tab (this can take some hours or one or two days).
     
    itzonator and Appossible like this.
  4. Appossible

    Appossible Avid Boxer

    Joined:
    Aug 14, 2017
    Messages:
    198
    Likes Received:
    56
  5. maxcar

    maxcar Boxer

    Joined:
    Sep 27, 2018
    Messages:
    23
    Likes Received:
    4
    Hey! Yes, I'm trying to accomplish the same thing as you mention in the thread. It would be ideal to track specific events to understand user behavior. I was able to follow a tutorial a while back and accomplish to use url buttons to send events, but my Andriod knowledge is limited so I don't know how to integrate the events into Game Analytics.

    Hook Layer For Android/ios
    https://www.buildbox.com/forum/inde...first-brick-for-advanced-customizations.6501/
     

Share This Page