Implement Analytics in Android Follow
This article describes how to implement analytics in your Android Meridian-powered app. Meridian uses Keen analytics.
If you’re using the Android SDK 5.9+, you’ll need to remove the Google dependency. If you’re using the Android SDK 5.8 or lower, you’ll need to keep the Google Analytics dependency, even though no Google Analytics data will be collected. .
Dependencies for Meridian Analytics
If you’d like to use Keen analytics in your project, you’ll need to add its dependency.
In the build.gradle
file inside dependencies { }
, add the Google Analytics dependency:
dependencies { // To enable analytics reporting for your SDK app:
include Keen Analytics dependency (Replace the `x.y.z` with the version used in the Samples app).
Uncomment Google Analytics dependency if you're using 5.8 or lower: // implementation 'com.google.android.gms:play-services-analytics:x.y.z' implementation 'io.keen:keen-client-api-android:x.y.z' implementation 'androidx.lifecycle:lifecycle-extensions:x.y.z'
// for 6.0 and below add the below dependency for lifecycle observer
annotationProcessor 'androidx.lifecycle:lifecycle-compiler:x.y.z'
// for 6.1 and above add the below dependency instead of the one above for lifecycle observer
implementation 'androidx.lifecycle:lifecycle-common-java8:x.y.z’
// For 6.3 and higher, add the following dependency
implementation('io.socket:socket.io-client:0.9.0') {
exclude group: 'org.json', module: 'json'
}
// After calling `Meridian.configure()`, call `MeridianAnalytics.setLocationId(locationId)` to start reporting stats for your location. }
If you’re using SDK 5.8 or lower, to finish enabling Google Analytics for your project, add the following to the build.gradle
file:
android { // ... defaultConfig { // ... buildConfigField "String", "ANALYTICS_ID", "TRACKING_ID" } }
Replace
TRACKING_ID
with your unique Google Analytics tracking ID. This is a string like UA-000000-2. It must be included in your tracking code to tell Google which account and property to send data to.
After calling Meridian.configure()
, call MeridianAnalytics.setAppId(appId)
to start reporting statistics for your location.
Comments
0 comments
Please sign in to leave a comment.