Flurry App Analytics for Android¶
You can gain deep insight into your customer’s behavior very quickly and with little effort using Flurry Analytics for Android. The SDK integration process is designed to be as easy as possible with a basic setup you can complete in a short period of time.
Flurry Analytics requires a minimum Android API level 10.
Flurry Analytics uses the Android Advertising ID provided by Google Play Services and will check for and respect the user’s ad tracking preference. For more information, visit Android Advertising ID.
If you are upgrading from one of the previous Flurry SDK versions, review the upgrade instructions: Upgrade to the Flurry Android SDK 5.x from SDK 4.x. You’ll need to add the FlurryAnalytics-5.x.x.jar to your project’s libs folder.
If you are working with versions prior to SDK 5.x, refer to Get Started With Android.
1. Get your API Keys¶
Start by creating an app. Once you create the app, you’ll receive a Flurry API Key, which you’ll need when using the SDK.Sign up or Create an App for Android
2. Download the Flurry Android SDK¶
There are currently two ways of getting the Flurry Android SDK into your application:
- Install via jCenter (Recommended):
The Flurry SDK is available via jCenter. You can add it to your application by including the following in your
- Download .jar files from Flurry Dev Portal
The downloaded archive should contain these files for use with Flurry Analytics:
- FlurryAnalytics_x.y.z.jar: The library containing Flurry’s analytic collection and reporting code (where x.y.x denotes the latest version of Flurry SDK).
- FlurryAds_x.y.z.jar: The optional library to incorporate Flurry’s ads into your application (where x.y.x denotes the latest version of Flurry SDK).
- ProjectApiKey.txt: This file contains the name of your project and your project’s API key.
- FlurryAndroidAnalyticsReadmevx.y.z.pdf: A PDF file with instructions (where x.y.x denotes the latest version of Flurry SDK).
3. Add the FlurryAnalytics_x.y.z.jar to your classpath¶
Using Android Studio:¶
If using Android Studio, you do not need to do anything further to include the Flurry SDK in your project, as long as you have installed the SDK through jCenter in your Gradle configuration.
However, if you prefer to use the downloaded .jar files, follow these procedures:
- Add FlurryAnalytics-5.x.x.jar to your project’s libs folder.
- Navigate to File > Project Structure > Module > Dependencies. Click the ‘+’ button in the bottom of the ‘Project Structure’ popup to add dependencies. Select ‘File dependency’ and add libs/FlurryAnalytics-5.x.x.jar.
- Add Google Play Services library. If selectively compiling individual Google Play Service APIs, you should include the Google Analytics API.
- Add FlurryAnalytics-5.x.x.jar to your project’s libs folder. Right-click on each JAR file and select Build Path > Add to Build Path.
- Add the Google Play Service library jar file.
Configure your AndroidManifest.xml¶
- Have access to the Internet and allow the Flurry SDK to check state of the network connectivity.
- Specify a versionName attribute in the manifest to have data reported under that version name.
- Declare min version of that Android OS that the app supports. Flurry supports Android OS versions 10 and above.
4. Add calls to
Follow these steps, adding these calls:
- If you are shipping an app, insert a call to
FlurryAgent.init(Context, String)in your
Applicationclass, passing it a reference to your application
Contextand your project’s API key:
Alternatively, you may call
init() just before
onStartSession(). It is safe to call
init() more than once, provided that you use the same API key throughout the application. You may use any type of
Context you wish.
If you wish to make calls to
logEvent(...) directly after a call to init, it is best to register the listener
FlurryAgentListener.onStartSession() for when the session has started. This will allow you to capture events as soon as the session is ready.
- If you are writing an app and the minimum target is Ice Cream Sandwich or above (minSdkVersion is set to API level 14 or greater), session handling is completely automatic, and you may skip steps 3 and 4. If you are instrumenting another type of Context, such as a Service, or your minimum target is Gingerbread, proceed with steps 3 or 4.
- Insert a call to
FlurryAgent.onStartSession(Context)in the Activity’s
onStart()method, passing it a reference to a Context object (such as an
Service). If you are targeting Gingerbread, Flurry recommends using the
onStart()method of each
Activityin your app, and passing the
Activityitself as the
Contextobject. For services (or other Contexts), use the
Serviceor the relevant
Contextobject. Do not pass in the global
- Insert a call to
FlurryAgent.onEndSession(Context)in the Activity’s onStop() method, when a session is complete. If you are targeting Gingerbread, we recommend using the onStop method of each Activity in your app. For services (or other Contexts), ensure that onStop is called in each instrumented Service. Make sure to match up a call to onEndSession for each call of onStartSession, passing in the same Context object that was used to call onStartSession. Do not pass in the global
As long as there is any Context that has called
onStartSession() but not
onEndSession(), the session will be continued. Also, if a new Context calls
onStartSession() within 10 seconds of the last Context calling
onEndSession(), then the session will be resumed, instead of a new session being created. Session length, usage frequency, events and errors will continue to be tracked as part of the same session. This ensures that as a user transitions from one
Activity to another in your app that they will not have a separate session tracked for each Activity, but will have a single session that spans many activities. If you want to track
Activity usage, Flurry recommends using
logEvent(), as described in the Custom Events section.
If you wish to change the window during which a session can be resumed, call
FlurryAgent.setContinueSessionMillis(long milliseconds) before the call to
The Flurry SDK automatically transfers the data captured during the session once the SDK determines the session completed. In case the device is not connected, the data is saved on the device and transferred once the device is connected again. The SDK manages the entire process. Currently, there is no way for the app to schedule the data transfer.
You’re done! That’s all you need to do to begin receiving basic metric data.
Following these steps provides you with access to the wide range of features listed below. In the Lexicon section of the documentation, you’ll find detailed descriptions of these features and terms.
- Active Users
- New Users
- Session Length
- Frequency of Use
- Page Views
- Custom User Segments
- Lifecycle Metrics
- User Retention
- Version Adoption
- Cross-App Usage
- Demographic Estimates
- Time of Day Reporting
- Geographic Usage
- Language Metrics
- Firmware Versions
Now that you’ve completed the basic setup, you are ready to move on to custom events, which enable you to better understand user behavior through tracking Custom Events.