Installation
At first 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.
Bitmovin Player v8+
If you are using the default Bitmovin Player package Bitmovin Analytics already comes pre-packaged with the Player, you just have to enable it via the Player configuration (in the PlayerConfig
)
Minimal Configuration
Setting up Bitmovin Analytics is very simple and fully integrated into the Bitmovin Player API. A minimal configuration can be set up in 5 lines of code.
1var player = bitmovin.player("player");2var analytics = new bitmovin.analytics.adapters.Bitmovin7Adapter(player) // This adds analytics to the player34player.setup({5 // Set up your Bitmovin Player normally with source attributes etc..67 // Add the analytics configuration here8 analytics: {9 key: "INSERT-ANALYTICS-KEY-HERE"10 };11});
By calling new bitmovin.analytics.adapters.Bitmovin7Adapter
analytics will augment the underlying player instance with all the instrumentation for Analytics to function.
Using Player v8
Bitmovin Player v8 comes pre-packaged with the Bitmovin Analytics Collector so there is no need to call new bitmovin.analytics.adapters.Bitmovin7Adapter
. If there is a analytics
section present in the player configuration it will just work™.
To ensure you are running a specific version (e.g. when including the bitmovin-analytics package from NPM) override the built-in analytics module:
1bitmovin.player.Player.addModule(bitmovin.analytics.PlayerModule);
Important: Make sure to call addModule
before creating the player instance. Otherwise the addModule
call has no effect.
Optional Fields and Important Fields
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}
Note that if you are using a player to play multiple videos, you will want to pass videoId
and title
for subsequent videos through the source config. This is explained at https://bitmovin.com/docs/analytics/tutorials/switching-to-a-new-video-with-web-collector-and-bitmovin-player
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 Data
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 Setup
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 have added all allowed domains correctly in your analytics license.