Integrating and using Flurry Analytics in an android application

Posted By : Daljeet Singh | 18-Dec-2017

Flurry analytics can be used in an android application to gain insights into a user's behaviour while navigating through the app.

By using Flurry analytics in your android application, you can keep track of various user metrics like total number of sessions, number of sessions by a single user,filtering the total number of sessions by country age or gender ,custom events occuring inside the app ,crash analytics etc.

The following steps explain integrating flurry analytics into your android application ,along with common use cases :

 

  • Step 1 : Add the following dependency in the build.gradle of your app :

    dependencies {
    	compile 'com.flurry.android:analytics:8.2.0@aar'
    }
    
  • Step 2 : Add the following piece of code in the onCreate method of your activity to initialize the Flurry SDK:

    @Override
        public void onCreate() {
            super.onCreate();
    
            new FlurryAgent.Builder()
                .withLogEnabled(true)
                .withCaptureUncaughtExceptions(true)
                .withContinueSessionMillis(20)
                .withLogLevel(VERBOSE)
                .build(this, FLURRY_KEY);
    }
    
    where FLURRY_KEY is your flurry key obtained by creating an app on the online flurry dashboard.You need to create a separate app and flurry key on the dashboard, for every distinct android application you want to integrate Flurry into.
  • Step 3 : Now that you have flurry tracking user sessions inside your activity,you can use it to get advanced user analytics by creating and logging custom events.

    For instance , the creators of an e-commerce application may be interested in knowing the number of users who add an item to the cart but don't check out or users who always checkout after adding an item to their cart.

    Such kind of analytics can be obtained by adding and logging a custom event whenever a user adds an item to the cart :

    addCartBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //code to add item to cart
            /*------*/
            //Logging the add to cart event along with the user's Id.
            Map<String, String> userParams = new HashMap<String, String>();
            userParams.put("UserId", "preference.getUserId");
            FlurryAgent.logEvent("add_to_cart", userParams);
        }
    });
    
    checkoutBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //code to begin the process of checkout
            /*------*/
            //Logging the checkout event along with the user's Id.
            Map<String, String> userParams = new HashMap<String, String>();
            userParams.put("UserId", "preference.getUserId");
            FlurryAgent.logEvent("checkout", userParams);
        }
    });
    

By creating user flows for the add to cart and checkout events in the dashboard,you can easily keep a track of the number of people who added an item to the cart but didn't checkout.

Crash Analytics don't require an explicit call to send crashes to Flurry on android,the data for your android app automatically flows into Flurry Crash Analytics.

About Author

Author Image
Daljeet Singh

Daljeet has experience developing android applications across a range of domains such as Cryptocurrency, Travel & Hotel Booking, Video Streaming and e-commerce. In his free time, he can be found playing/watching a game of football or reading up on either

Request for Proposal

Name is required

Comment is required

Sending message..