Sending Brightcove Analytics from the Native SDK for Android

Product(s)
Video Cloud
Role(s)
Device SDK Developer
Topic(s)
Analytics
SDK
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 4.2.7 of the Brightcove Mobile SDK for Android, you can send custom values to Brightcove Analytics from your app for Account Id, Destination URI and Source URI.

Your Account Id is required, but is automatically set when you use the Brightcove player and the catalog.

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.setAccount("your accountID");
analytics.setDestination("valid URI");
analytics.setSource("valid URI");

Account

Use the account 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 accountId property as follows:

brightcoveVideoView.getAnalytics().setAccount("your accountId");

When you set the account property, the value of this property will be used for any of your videos which do not already have an accountId property. The most useful value for this property is your own 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.

For Video Cloud videos, setting this account override has no effect on reporting, since the video's accountId metadata value remains unchanged. That value can not be overridden by setting this account value.

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.