On This Page

Data Collection API Sample

Product(s)

Video Cloud

Role(s)

API Developer

Device SDK Developer

Topic(s)

Analytics

Code Samples

API(s)

Analytics API

In this sample, you will learn how to send information to the Data Collector so that you can get analytics data for videos that are not viewed in a Brightcove web or SDK player. Note that this technique should not be used if you are using the Brightcove web or SDK players, as it will result in duplicated analytics data.

This sample shows how to send analytics data to the Brightcove Data Collector from a non-Brightcove player (in this case, the Video.js player).

Notes on the sample

The code for this sample is all JavaScript, and there are two parts (both found in the CodePen: the plugin script is at the top, and a short piece of code that adds the plugin to the player at the bottom):

The script that adds the plugin to the videojs player

The script for the plugin that sends data to the Data Collector

Note that the way the data is "sent" to the Data Collection API is by setting the request URL as the src value for a new image (img) element and then injecting that element into the page.

You should use the same method rather than XMLHttpRequest or some other in order to avoid CORS issues.