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); }
-
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.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
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