Sending Brightcove Analytics from the Native SDK for iOS

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

Analytics integration

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

If you override the BCOVVideo 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 6.12.4 of the Brightcove Mobile SDK for iOS, you can send custom values to Brightcove Analytics from your app to Brightcove Analytics:

  • Player ID
  • Player Name
  • Application ID
  • 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 ViewController implementation file. This is typically done after the call to create the PlaybackController:

id<BCOVPlaybackController> controller =
    [[BCOVPlayerSDKManager sharedManager] createPlaybackController];

controller.analytics.destination = valid URI;
controller.analytics.source = valid URI;
controller.analytics.player = My-player-id;
controller.analytics.playerName = My-player-name;
controller.analytics.applicationid = My Application Name;

Account

Here's an example of setting Account ID for a single video:

  BCOVVideo *video = [BCOVVideo videoWithHLSSourceURL:[NSURL URLWithString:@"http://url.to.content/master.m3u8"]];
    video = [video update:^(id<BCOVMutableVideo>  _Nonnull mutableVideo) {
        NSMutableDictionary *updatedProperties = mutableVideo.properties.mutableCopy;
        updatedProperties[kBCOVVideoPropertyKeyAccountId] = @"your accountID";
        mutableVideo.properties = updatedProperties;
    }];

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's bundle identifier as listed in the app's info.plist file.

For example, in an iOS Sample app, the default destination value would be bcsdk://com.brightcove.sampleAppMainScreen.Destination and it could be overridden like this:

controller.analytics.destination =
    @"myapp://com.mycompany.homescreen.destination";

Any screen in your app that instantiates a BCOVPlaybackController 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 nil. When the value is nil, the source property is not sent to the Analytics server.

Here is an example of how to set the source property:

controller.analytics.source =
    @"myapp://com.mycompany.homescreen.destination.source";

Player ID

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

Player Name

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

Application ID

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