HTML5 is general library, which use HTML5 video tag for tracking playback info. It needs: HTML5 video element and configuration JSON object . This library connects to video element and monitors playback process. It sends data during playback to bradmax analytics platform.
This library can be used, when you use native video element or player, which simply “wraps” video element.
Raw JavaScript file: https://bradmax.com/static/bradmax-analytics-for-players/latest/bradmax.analytics.js
Zipped JavaScript file: https://bradmax.com/static/bradmax-analytics-for-players/latest/bradmax.analytics.zip
Class: bradmax.analytics.Html5
Field | Description |
---|---|
bradmaxAnalytics | Library object, which sends data to bradmax analytics platform |
mediaElement | Associated video element |
Methods | Description |
---|---|
constructor(videoElement, configuration: Object) | creates API object with selected video element and JSON configuration object. |
destroy() | Destroys API (disconnects from video element and performs clean up operations). |
Initial steps:
<!DOCTYPE html>
<html>
<head>
<title>HTML5 / Bradmax analytics</title>
<!-- Bradmax analytics -->
<script src="https://example.com/bradmax.analytics.js"></script>
<script>
function initApp() {
var element = document.getElementById("video");
var config = {
clientToken: "SJnO!AzdDggLdOyAIdBg5DIjjeIOMAFd9gADV"
};
var api = new bradmax.analytics.Html5(element, config);
}
document.addEventListener("DOMContentLoaded", initApp);
</script>
</head>
<body>
<h2>HTML5 / Bradmax analytics</h2>
<!-- HTML5 video tag -->
<video id="video" controls poster="https://bradmax.com/static/images/startsplash.jpg" width="600" height="400" src="https://bradmax.com/static/video/tears_of_steel.mp4">
</video>
</body>
</html>
Example above will track only general information about playback and only: Audience, Technology and Geo reports will be available.
Parameter “mediaMetadata” has to be added into configuration object. See example below. More info about mediaMetadata
<!DOCTYPE html>
<html>
<head>
<title>HTML5 / Bradmax analytics</title>
<!-- Bradmax analytics -->
<script src="bradmax.analytics.js"></script>
<script>
function initApp() {
var element = document.getElementById("video");
var config = {
clientToken: "SJnO!AzdDggLdOyAIdBg5DIjjeIOMAFd9gADV",
mediaMetadata: {
materialId: "701",
relatedId: "7001",
duration: 734,
title: "Tears of Steel",
tags: ["test", "entertaiment"]
}
};
var api = new bradmax.analytics.Html5(element, config);
}
document.addEventListener("DOMContentLoaded", initApp);
</script>
</head>
<body>
<h2>HTML5 / Bradmax analytics</h2>
<!-- HTML5 video tag -->
<video id="video" controls poster="https://bradmax.com/static/images/startsplash.jpg" width="600" height="400" src="https://bradmax.com/static/video/tears_of_steel.mp4">
</video>
</body>
</html>
It is only needed to add parameter
trackEngagementRate: true
into configuration object.
<!DOCTYPE html>
<html>
<head>
<title>HTML5 / Bradmax analytics</title>
<!-- Bradmax analytics -->
<script src="bradmax.analytics.js"></script>
<script>
function initApp() {
var element = document.getElementById("video");
var config = {
clientToken: "SJnO!AzdDggLdOyAIdBg5DIjjeIOMAFd9gADV",
trackEngagementRate: true,
mediaMetadata: {
materialId: "701",
relatedId: "7001",
duration: 734,
title: "Tears of Steel",
tags: ["test", "entertaiment"]
}
};
var api = new bradmax.analytics.Html5(element, config);
}
document.addEventListener("DOMContentLoaded", initApp);
</script>
</head>
<body>
<h2>HTML5 / Bradmax analytics</h2>
<!-- HTML5 video tag -->
<video id="video" controls poster="https://bradmax.com/static/images/startsplash.jpg" width="600" height="400" src="https://bradmax.com/static/video/tears_of_steel.mp4">
</video>
</body>
</html>
It is only needed to add parameter
trackRealtimeStats: true
into configuration object.
<!DOCTYPE html>
<html>
<head>
<title>HTML5 / Bradmax analytics</title>
<!-- Bradmax analytics -->
<script src="bradmax.analytics.js"></script>
<script>
function initApp() {
var element = document.getElementById("video");
var config = {
clientToken: "SJnO!AzdDggLdOyAIdBg5DIjjeIOMAFd9gADV",
trackEngagementRate: true,
trackRealtimeStats: true
mediaMetadata: {
materialId: "701",
relatedId: "7001",
duration: 734,
title: "Tears of Steel",
tags: ["test", "entertaiment"]
}
};
var api = new bradmax.analytics.Html5(element, config);
}
document.addEventListener("DOMContentLoaded", initApp);
</script>
</head>
<body>
<h2>HTML5 / Bradmax analytics</h2>
<!-- HTML5 video tag -->
<video id="video" controls poster="https://bradmax.com/static/images/startsplash.jpg" width="600" height="400" src="https://bradmax.com/static/video/tears_of_steel.mp4">
</video>
</body>
</html>