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

If you use the Brightcove player and catalog included in the SDK to retrieve and play videos, analytics data will be automatically collected and will appear in the Video Cloud Analytics module.

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

Customize properties

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

  • Destination URI
  • Source URI

You can set the 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");

Account

Use the Video.Fields.PUBLISHER_ID property to set the Account Id value in Brightcove Analytics. This property will be 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 will be used for this remote video only. It will 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 will 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.

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 how, view the following docs:

Note: Brightcove Analytics converts the destination and source values you’ve set to an all lower-case string value in all reports.