The following procedure describes the steps required to implement real-time video tracking in
your player using the video heartbeat library. The required components must be
instantiated and configured at the application level, in the order given here:
- Instantiate and configure the VisitorAPI library
- Create an instance of the AppMeasurement library. This instance must
aggregate the VisitorAPI instance. Also, the AppMeasurement instance must
explicitly load the module that deals with media-specific tracking. There is
a specific public method exposed for this particular purpose (see code
samples below).
- Create the video heartbeat library which in turn aggregates the
AppMeasurement instance created during the previous step.
In summary, the application developer is in charge of instantiating all of the
video-tracking components while managing this dependency chain: VisitorAPI ->
AppMeasurement/AppMeasurement_Module_Media -> video heartbeat.
The ABD global module - In order to keep the JavaScript global namespace as clean as
possible, the video heartbeat library defines a specific global-level module that
acts as a namespace. This module is called ADB. All symbols exposed by this library
through its public API are made available as properties attached to the ADB module.
The set of exposed symbols is further segmented into sub-namespaces. Of particular
interest to the application developer is the heartbeat sub-namespace, which
publishes all symbols related to video-tracking APIs. Obtaining a reference to the
VideoHeartbeat() constructor function can be done as
follows:
var VideoHeartbeat = ADB.heartbeat.VideoHeartbeat
-
Instantiate and configure the VisitorAPI component:
// Instantiation
var visitor = new Visitor("Visitor namespace");
// Configuration
visitor.trackingServer = "Visitor tracking endpoint";
Instantiating the Visitor API component requires an input namespace parameter. This is a
pure string value.
There is only one configuration option available for the VisitorAPI component -- the URL of
the back-end endpoint that provides the unique "label" for the current user.
-
Instantiate and configure the AppMeasurement component:
// Instantiation
var appMeasurementObject = new AppMeasurement();
appMeasurementObject.account = "Account name";
// Use the same value here that you provided in Step 1 for Visitor API.
appMeasurementObject.visitorNamespace = "Visitor namespace";
// This is the Adobe Analytics (SiteCatalyst) endpoint
appMeasurementObject.trackingServer = "Adobe Analytics tracking server endpoint";
// Attach the VisitorAPI to the AppMeasurement instance.
appMeasurementObject.visitor = visitor;
// Explicitly load the "Media" module
appMeasurementObject.loadModule("Media");
There
are many configuration options available on the AppMeasurement instance that are
not shown here. (See the Adobe Analytics Developer page for
more configuration options.) The three options shown in the sample code above
are required (account, visitorNamespace,
trackingServer).It is important to properly set up the
dependency chain:
- The AppMeasurement instance aggregates (depends on) the Visitor API
component.
- The application developer must explicitly load the media module by
calling the loadModule("Media") method. The code
for the media module is inside the
AppMeasurement_Module_Media.min.js file.
-
Instantiate and configure the video heartbeat component.
Instantiating video heartbeat is a two-step process, due to its dependency on these two
components:
- The AppMeasurement component
- An implementation of the PlayerDelegateProtocol
interface.
It is the responsibility of the video player
developer to implement and instantiate the
PlayerDelegateProtocol interface. Once this
implementation is in place, the instantiation process is very
straightforward:
Instantiate the video heartbeat
component:
var VideoHeartbeat = ADB.heartbeat.VideoHeartbeat;
// The CustomPlayerDelegate class implements the PlayerDelegateProtocol interface.
var playerDelegate = new CustomPlayerDelegate();
// We now have all ingredients to instantiate the video heartbeat library.
var videoHeartbeat = new VideoHeartbeat(appMeasurementObject, playerDelegate);
Configure
the newly created video heartbeat
instance:
var ConfigData = ADB.heartbeat.ConfigData;
// Instantiate the configuration object
var heartbeatConfig = new ConfigData();
heartbeatConfig.playerName = "the name of your player app";
heartbeatConfig.trackingServer = "video heartbeat tracking server URL";
heartbeatConfig.jobId = "Your JOB-ID";
heartbeatConfig.publisher = "Publisher name";
heartbeatConfig.ovp = "The name of the online video platform (like youtube etc)";
heartbeatConfig.sdk = "The version of your video player";
// Set this to true to activate the debug tracing
heartbeatConfig.debugLogging = false;
// Explicitly activate the video heartbeat functionality.
heartbeatConfig.enableHeartbeat = true;
videoHeartbeat.config(heartbeatConfig);
Important: In the code listing above, notice the explicit activation
of the heartbeat tracking functionality. The application developer needs to
set the enableHeartbeat flag to true
inside the configuration object. If this step is omitted, no heartbeat
calls will be sent over the network.
Note: Setting the
debugLogging flag to true activates
extensive tracing messaging, which may impact performance. While tracing is
useful during development and debugging efforts, the application developer
must set this to false for the production version of the player app. The
logging mechanism is disabled by default.