Skip to content

bitmovin/bitmovin-analytics-collector-android

main
Switch branches/tags
Code

bitmovin

Android client that allows you to monitor your Bitmovin Native SDK or ExoPlayer playback with Bitmovin Analytics.

Getting started

Gradle

Add this to your top level build.gradle

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

And this line to your main project build.gradle

For Bitmovin Player v2:

dependencies {
    implementation 'com.bitmovin.analytics:collector-bitmovin-player:1.33.0'
}

For Bitmovin Player v3:

dependencies {
    implementation 'com.bitmovin.analytics:collector-bitmovin-player:2.9.0'
}

For ExoPlayer < v2.12.0:

dependencies {
    implementation 'com.bitmovin.analytics:collector-exoplayer:1.33.0'
}

For ExoPlayer version between >= v2.12.0 and < v2.17.0:

dependencies {
    implementation 'com.bitmovin.analytics:collector-exoplayer:2.6.2'
}

For ExoPlayer version between >= v2.17.0 and < v2.18.0:

dependencies {
    implementation 'com.bitmovin.analytics:collector-exoplayer:2.9.0'
}

Examples

The following example creates a BitmovinAnalytics object and attaches an Bitmovin Native SDK instance to it.

Basic analytics monitoring with Bitmovin Player SDK

// Create a BitmovinAnalyticsConfig using your Bitmovin analytics license key and (optionally) your Bitmovin Player Key
BitmovinAnalyticsConfig bitmovinAnalyticsConfig = new BitmovinAnalyticsConfig("<BITMOVIN_ANALYTICS_KEY>", "<BITMOVIN_PLAYER_KEY>");


// Create a BitmovinPlayerCollector object using the BitmovinAnalyitcsConfig you just created
BitmovinPlayerCollector analyticsCollector = new BitmovinPlayerCollector(bitmovinAnalyticsConfig, getApplicationContext());

// 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();

Basic analytics monitoring with ExoPlayer

// Create a BitmovinAnalyticsConfig using your Bitmovin analytics license key
BitmovinAnalyticsConfig bitmovinAnalyticsConfig = new BitmovinAnalyticsConfig("<BITMOVIN_ANALYTICS_KEY>");

Create Analytics Collector for ExoPlayer
ExoPlayerCollector bitmovinAnalytics = new ExoPlayerCollector(bitmovinAnalyticsConfig, getApplicationContext());

//Attach your ExoPlayer instance
bitmovinAnalytics.attachPlayer(player);

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

Switching to a new video

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.setVideoId("newVideoId");
bitmovinAnalyticsConfig.setCustomData1("newCustomData");

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

Optional Configuration Parameters

bitmovinAnalyticsConfig.setVideoId("videoId1234");
bitmovinAnalyticsConfig.setCustomUserId("customUserId1");
bitmovinAnalyticsConfig.setCdnProvider(CDNProvider.BITMOVIN);
bitmovinAnalyticsConfig.setExperimentName("experiment-1");
bitmovinAnalyticsConfig.setCustomData1("customData1");
bitmovinAnalyticsConfig.setCustomData2("customData2");
bitmovinAnalyticsConfig.setCustomData3("customData3");
bitmovinAnalyticsConfig.setCustomData4("customData4");
bitmovinAnalyticsConfig.setCustomData5("customData5");
bitmovinAnalyticsConfig.setCustomData6("customData6");
bitmovinAnalyticsConfig.setCustomData7("customData7");
bitmovinAnalyticsConfig.setIsLive(false);

A full example app can be seen in the github repo

Support

If you have any questions or issues with this Analytics Collector or its examples, or you require other technical support for our services, please login to your Bitmovin Dashboard at https://bitmovin.com/dashboard and create a new support case. Our team will get back to you as soon as possible 👍