[object Object] Icon

Encoding
Learn how to create, start, manage and modify Encodings

[object Object] Icon

Player
Learn how to create, start, manage and modify Players

[object Object] Icon

Analytics
Learn how to create, start, manage and modify Analyticss

Docs Home
User shortcuts for search
Focus by pressing f
Hide results by pressing Esc
Navigate via   keys

Fri Jan 04 2019

Integrating Bitmovin Analytics with VideoJS

InstallationLink Icon

Firstly you have to add the Bitmovin Analytics Collector to your website. Therefore, please add the following <script></script> tag to the head of your page:

Install from CDN

1<script type="text/javascript" src="https://cdn.bitmovin.com/analytics/web/2/bitmovinanalytics.min.js"></script>

Install via NPM

If you prefer to package the Bitmovin Analytics collector with your own build pipeline please use the bitmovin-analytics package from the NPM registry via npm: npm install bitmovin-analytics.

To import the VideoJS Adapter just use regular ES6 style imports. Bitmovin Analytics collector is UMD and ES6 compatible.

1import { VideojsAdapter } from 'bitmovin-analytics';

Integration into Shaka Player

After importing analytics you need to create the VideojsAdapter by passing the analytics configuration and your VideoJS instance. A typical setup would look like this:

1var player = videojs('my-video', vjsOptions);
2new bitmovin.analytics.adapters.VideojsAdapter(analyticsConfig, player);

Where the analytics config is described in the following section

Minimal ConfigurationLink Icon

Bitmovin Analytics requires at least a license key to be configure.

1const config = { key: "INSERT-ANALYTICS-KEY-HERE" };

Optional Fields and Important FieldsLink Icon

While the minimum configuration is the bare minimum to get started, the following fields are strongly recommended to be set:

  • videoId
  • title
  • cdnProvider

VideoId & Title

Supplying a videoId to Analytics makes it easy to distinguish between played contents so it is highly recommended to set this setting to something that corresponds with your System (usually a CMS Id or some string that identifies the Video for you). It is also advised to set the title field to something human-readable so you don't have to remember Ids when searching for things in the Analytics Dashboard)

Setting the videoId as well as the title is simple.

1var analyticsConfig = {
2 key: "INSERT-ANALYTICS-KEY-HERE",
3 videoId: "YOUR-VIDEO-ID",
4 title: "A descriptive video title"
5}

CDN Provider

If you are using multiple CDNs or plan to test with different CDNs in the future it's very helpful to set the cdnProvider parameter to be able to compare performance between the CDNs. You can specify any string, but we have built in some constants that are available on bitmovin.analytics.CdnProviders or by importing it with import { CdnProviders } from 'bitmovin-analytics'.

  • BITMOVIN
  • AKAMAI
  • FASTLY
  • MAXCDN
  • CLOUDFRONT
  • CHINACACHE
  • BITGRAVITY

Custom DataLink Icon

It is possible to supply custom data to Bitmovin Analytics. We support 5 fields for custom data as well as experimentName which can be used to A/B Test your setup.

CustomData fields include:

  • customData1
  • customData2
  • customData3
  • customData4
  • customData5

Verify your SetupLink Icon

To test if your setup is working you can just go to your Analytics Dashboard to check if your sessions are being recorded already. If you don't see any sessions, please check if you are using the correct analytics key, and you white-listed all domains correctly in your analytics license.

Give us feedback