Sending Brightcove Analytics from the Native SDK for Android

In this topic, you will learn how to set properties in Brightcove Analytics from your mobile app using the Brightcove SDK for Android.

Analytics integration

Suppose you use the Brightcove player and catalog included in the SDK to retrieve and play videos. In that case, analytics data are automatically collected and appear in the Video Cloud Analytics module.

If you override the BrightcoveVideoView class or do not use the Brightcove player and catalog, you must to send your Account Id to Video Cloud Analytics.

Customize properties

As of version 8.2.3 of the Brightcove Mobile SDK for Android, you can send the following custom values from your app to Brightcove Analytics:

  • Player ID
  • Player Name
  • Application ID
  • Destination URI
  • Source URI

You can set the Player, Player Name, Application, Destination and Source URIs if you choose. The default values are based on the application package name.

These properties can be set in your Android MainActivity class file:

brightcoveVideoView = (SeamlessVideoView) findViewById(R.id.brightcove_video_view);
Analytics analytics = brightcoveVideoView.getAnalytics();
analytics.setDestination("valid URI");
analytics.setSource("valid URI");
analytics.setApplication("My Application Name");
analytics.setPlayerName("My Player Name");
analytics.setPlayerID("My-player-id");

Account

Use the Video.Fields.PUBLISHER_ID property to set the Account Id value in Brightcove Analytics. This property is useful only in cases where there is no accountID value in the video's metadata (for example, if your app uses a mix of Video Cloud videos, which contain the accountID property, and non-Video Cloud videos, which will not contain the accountID property).

For example, you can set the Account Id value when creating a remote Video object using the Native SDK for Android:

Video video = Video.createVideo("http://url.to.content/master.m3u8", DeliveryType.HLS);
 video.getProperties().put(Video.Fields.PUBLISHER_ID, "your accountID");

When you set the Video.Fields.PUBLISHER_ID property, the value of this property is used for this remote video only. It does not affect the reporting of any VideoCloud videos you may also use. The most useful value for this property is your Account Id. These videos are be reported in the Analytics module as Other/Third Party since Brightcove Analytics does not currently support detailed reporting for videos that are not retrieved through the Brightcove Catalog service.

Destination

Use the destination property to set the value of the location that originates the event. The value of the destination property MUST be in proper URI format, similar to this example:

bcsdk://com.mhogben.source

The default value the destination property is bcsdk:// followed by the app name, followed by the package name.

For example, in the Android SDK HLS Sample App, the destination value would be:

bcsdk://HLSSampleApp/com.brightcove.player.samples.hls.basic

Any screen in your app that instantiates a brightcoveVideoView can set this destination override to a distinct value, to better track video views within the app itself.

Source

Use the source property to set the URI that sent the end-user to the destination URI. As with the destination value, the value of the source property MUST be in proper URI format, similar to this example:

bcsdk://com.mhogben.source

The default value of the source property is null. When the value is null, the source property is not sent to the Analytics server.

For example, you can set the source property as follows:

brightcoveVideoView.getAnalytics().setSource("bcsdk://com.brightcove.HLSPlayerSampleAppSource");

Note: For more details about URI structures for use in the destination and source fields, see the URI Scheme Wikipedia page. You can use a tool like this URL Encoder to convert characters into UTF-8 encoding format.

Player ID

Use the player property to set the ID of the player.

Player Name

Use the player_name property to set the name of the player, (This is the same name you see in the Studio list of players).

Application ID

The application field is not a field in itself but a custom string to identify the usage of the player.

View analytics

In the Video Cloud Analytics module, you can view metric data at the account level or at a detailed level such as by video. To learn more, see: