Android tracker Setup - OXYGEN-MARKET/oxygen-market.github.io GitHub Wiki

HOME > SNOWPLOW SETUP GUIDE > Step 2: setup a Tracker > Android tracker

Contents

1. Overview

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.

Back to top

2. Integration options

2.1 Tracker compatibility

The Snowplow Android Tracker has been built and tested using the Android SDK version 24, but uses a minimum SDK version of 11, so should work within any Android application built using SDK version 11 upwards.

Back to top

2.2 Dependencies

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. The current dependencies:

compile 'com.squareup.okhttp3:okhttp:3.4.1'

Back to top

3. Setup

3.1 Hosting

The Tracker is published to jcenter, 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.6.2.

3.2 Gradle

If you are using Gradle in your own Android application, you will need to ensure jcenter() is in your build.gradle file:

repositories {
    ...
    jcenter()
}

Then add into the same file:

dependencies {
    ...
    // Snowplow Android Tracker
    compile 'com.snowplowanalytics:snowplow-android-tracker:0.6.2@aar'
}

This will install version 0.6.2 of the android tracker. However if you would like to ensure that all bug fixes and patches for version 0.6.2 are installed, simply change 0.6.2 into 0.6.+.

Please note that no breaking changes will occur in the '0.6.x' space.

dependencies {
    ...
    // Snowplow Android Tracker
    compile 'com.snowplowanalytics:snowplow-android-tracker:0.6.+@aar'
}

3.3 Permissions

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" />

4. Example Gradle Dependencies

The dependencies for the implementation of the Android Tracker goes as follows:

repositories {
    maven {
        url "http://maven.snplow.com/releases"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.android.support:appcompat-v7:22.2.0'

    // Optional Google Analytics Library
    // - Required to get the IDFA Code
    compile 'com.google.android.gms:play-services-analytics:7.5.0'

    // Required Dependency for the Tracker
    compile 'com.squareup.okhttp3:okhttp:3.4.1'

    // Tracker Import
    compile 'com.snowplowanalytics:snowplow-android-tracker:0.6.2@aar'
}

Done? Now read the Android Tracker API to start tracking events.

⚠️ **GitHub.com Fallback** ⚠️