Android Tracker Setup 0.4.0 - OXYGEN-MARKET/oxygen-market.github.io GitHub Wiki
HOME > SNOWPLOW SETUP GUIDE > Step 2: setup a Tracker > Android tracker
-
- 2.1 Tracker compatibility
- 2.2 Dependencies
-
- 3.1 Hosting
- 3.2 Maven
- 3.3 Gradle
- 3.3.1 Android Archive
- 3.4 Permissions
The Snowplow Android Tracker lets you add analytics to your Android-based mobile apps and games.
The Tracker should be relatively straightforward to setup if you are familiar with Java/Android development.
Ready? Let's get started.
The Snowplow Android Tracker has been built and tested using the Android SDK version 21, but uses a minimum SDK version of 11, so should work within any Android application built using SDK version 11 upwards.
To minimize the dex footprint of the Tracker we have kept dependencies to an absolute minimum.
To minimize jar bloat, we have tried to keep external dependencies to a minimum. For the full list of dependencies, please see our core Gradle build file, classic Gradle build file and our rx Gradle build file.
The Tracker is published to Snowplow's hosted Maven repository, which should make it easy to add it as a dependency into your own Android app.
The current version of the Snowplow Android Tracker is 0.4.0.
If you are using Maven for building your Android application, then add the following code into your HOME/.m2/settings.xml
to be able to use this repository:
<settings>
<profiles>
<profile>
<!-- ... -->
<repositories>
<repository>
<id>com.snowplowanalytics</id>
<name>SnowPlow Analytics</name>
<url>http://maven.snplow.com/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
</settings>
Then add into your project's pom.xml
for the classic Tracker:
<dependency>
<groupId>com.snowplowanalytics</groupId>
<artifactId>snowplow-android-tracker-classic</artifactId>
<version>0.4.0</version>
</dependency>
...and for the RxJava Tracker:
<dependency>
<groupId>com.snowplowanalytics</groupId>
<artifactId>snowplow-android-tracker-rx</artifactId>
<version>0.4.0</version>
</dependency>
If you are using Gradle in your own Android application, then add our Maven repository in your build.gradle
file:
repositories {
...
maven {
url "http://maven.snplow.com/releases"
}
}
Then add into the same file:
dependencies {
...
// Snowplow Android Tracker
// For Classic
compile 'com.snowplowanalytics:snowplow-android-tracker-classic:0.4.0'
// For RxJava
compile 'com.snowplowanalytics:snowplow-android-tracker-rx:0.4.0'
}
This will install version 0.4.0
of the android tracker. However if you would like to ensure that all bug fixes and patches for version 0.4.0
are installed, simply change 0.4.0
into 0.4.+
.
Please note that no breaking changes will occur in the '0.4.x' space.
dependencies {
...
// Snowplow Android Tracker
// For Classic
compile 'com.snowplowanalytics:snowplow-android-tracker-classic:0.4.+'
// For RxJava
compile 'com.snowplowanalytics:snowplow-android-tracker-rx:0.4.+'
}
You can also add the Android Tracker using the Android ARchive (aar) package in your gradle file in a similar way to the Gradle version while appending '@aar' to the end:
dependencies {
...
// Snowplow Android Tracker
// For Classic
compile 'com.snowplowanalytics:snowplow-android-tracker-classic:0.4.+@aar'
// For RxJava
compile 'com.snowplowanalytics:snowplow-android-tracker-rx:0.4.+@aar'
}
To send the events, you need to update your AndroidManifest.xml
with the internet access permission:
<uses-permission android:name="android.permission.INTERNET" />
To have the emitter check for online status before sending you will need to add the following:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
If you want to send location information with each event you will need to add the following permissions to your AndroidManifest.xml
:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
Done? Now read the Android Tracker API to start tracking events.