Analytics Android Collector v2

This doc describes the setup for the deprecated analytics collector v2. We highly recommend upgrading to the latest version as described here.

How to set up the Android Collector

Bitmovin Analytics enables you to get useful insights into the video usage in your apps. Our Android Collector offers a simple integration with our Bitmovin Player, the Exoplayer and the Amazon IVS Player.

In order to follow along this guide, you need at least a basic setup of your chosen Player. If you haven't set up your Player yet, go to the corresponding Player documentation pages: Bitmovin Player getting started guide, ExoPlayer documentation, Amazon IVS Player documentation.

You also need to set up your analytics license and allowlist your domain. If you haven't done this yet, go to our How to Set Up page and follow the steps there.

Platform requirements:

CollectorSupported Android Version
Bitmovin Player CollectorAndroid 5+
Exoplayer CollectorAndroid 5+
Amazon IVS Player CollectorAndroid 5+

Step 1: Add the SDK to Your Project.

Add the Bitmovin release repository to your project

Add a link to our release repository to your application's build.gradle file. In addition to that, the google maven repository must be added.

allprojects {
    repositories {
        mavenCentral()
        google()

        maven {
            url 'https://artifacts.bitmovin.com/artifactory/public-releases'
        }
    }
}

Add the Dependency to the Project

Add the Bitmovin Analytics Android SDK as a dependency to your main project's build.gradle file as shown below, while replacing {Version Number} with the desired SDK version number. The available SDK versions are listed in our Release Notes. We recommend to always stay up to date with both player and collector versions. However if you are using an older player version, check out which collector version you should use at our Android Collector Github page.

dependencies {
    implementation 'com.bitmovin.analytics:collector-bitmovin-player:{Version Number}'
}
dependencies {
    implementation 'com.bitmovin.analytics:collector-exoplayer:{Version Number}'
}
dependencies {
    implementation 'com.bitmovin.analytics:collector-amazon-ivs:{Version Number}'
}

Step 2: Setup the Collector

First create a basic BitmovinAnalyticsConfig object by using your Bitmovin analytics license key and optionally your Bitmovin Player Key. You can further customise it by adding optional configuration parameters. For more information and a complete list of configuration fields see our Configuration Guide.

Please replace ANALYTICS_LICENSE_KEY with a license key from your account. Please checkout How to set up to learn more about how to get to your analytics license.

Create the collector object by passing the config object. Finally attach your player to the collector. Always detach your player from the collector once you are done, e.g. when calling the player.release() method.

// Create a BitmovinAnalyticsConfig using your Bitmovin analytics license key and (optionally) your Bitmovin Player Key
val bitmovinAnalyticsConfig = BitmovinAnalyticsConfig("<ANALYTICS_LICENSE_KEY>", "<PLAYER_LICENSE_KEY>")

// Optionally add further configuration parameters, for more information see our Configuration Guide
bitmovinAnalyticsConfig.videoId = "videoId1234"

// Create a BitmovinPlayerCollector object using the BitmovinAnalyitcsConfig you just created
val analyticsCollector = IBitmovinPlayerCollector.Factory.create(bitmovinAnalyticsConfig, applicationContext)

// Attach your player instance
analyticsCollector.attachPlayer(player)

// Detach your player when you are done. For example, call this method when you call the release() method
analyticsCollector.detachPlayer()
// Create a BitmovinAnalyticsConfig using your Bitmovin analytics license key
val bitmovinAnalyticsConfig = BitmovinAnalyticsConfig("<ANALYTICS_LICENSE_KEY>")

// Optionally add further configuration parameters, for more inforamtion see our Configuration Guide
bitmovinAnalyticsConfig.videoId = "videoId1234"

// Create Analytics Collector for ExoPlayer
val analyticsCollector = IExoPlayerCollector.Factory.create(bitmovinAnalyticsConfig, applicationContext)

// Attach your ExoPlayer instance
analyticsCollector.attachPlayer(player)

// Detach your player when you are done. For example, call this method when you call ExoPlayer's release() method
analyticsCollector.detachPlayer()
// Create a BitmovinAnalyticsConfig using your Bitmovin analytics license key
val bitmovinAnalyticsConfig = BitmovinAnalyticsConfig("<ANALYTICS_LICENSE_KEY>")

// Optionally add further configuration parameters, for more inforamtion see our Configuration Guide
bitmovinAnalyticsConfig.videoId = "videoId1234"

// Create Analytics Collector for Amazon IVS Player
val analyticsCollector = IAmazonIvsPlayerCollector.Factory.create(bitmovinAnalyticsConfig, applicationContext)

// Attach your Amazon IVS Player instance
analyticsCollector.attachPlayer(player)

// Detach your player when you are done. For example, call this method when you call the release() method
analyticsCollector.detachPlayer()

When switching to a new video we recommend that you follow the sequence of events below.

// Detach your player when the first video is completed
analyticsCollector.detachPlayer()

// Update your config with new optional parameters related to the new video playback
bitmovinAnalyticsConfig.videoId = "newVideoId"
bitmovinAnalyticsConfig.customData1 = "newCustomData"

// Reattach your player instance
analyticsCollector.attachPlayer(newPlayer)

Step 3: Check Statistics in Dashboard

After the setup is done there is nothing more to do. Events are recorded automatically and you can head over to the Analytics Dashboard to see statistics.

Examples

You can find fully functional code examples in our Github Repository.