Teyuto provides a seamless solution for managing all your video distribution needs. Whether you require video distribution in the cloud, on OTT platforms, storage, public OTT platform distribution, or secure intranet distribution, Teyuto puts everything at your fingertips, making the management of your video content effortless.
Teyuto Player Analytics SDK enables easy integration of analytics tracking for video playback using Video.js, HLS.js, Plyr, or Shaka Player.
Include the SDK in your HTML:
<script src="https://cdn.jsdelivr.net/gh/Teyuto/teyuto-player-analytics-sdk@production/src/TeyutoPlayerAnalytics.min.js"></script>
Install via npm:
npm install teyuto-player-analytics
import { TeyutoVideoJsAdapter } from 'teyuto-player-analytics';
const player = videojs('my-video');
const analytics = new TeyutoVideoJsAdapter('your-channel-public', 'user-token');
analytics.init(player, 'video-id');
// Clean up
window.addEventListener('beforeunload', () => {
analytics.destroy();
player.dispose();
});
import { TeyutoHlsJsAdapter } from 'teyuto-player-analytics';
const video = document.getElementById('video');
const hls = new Hls();
hls.loadSource('https://example.com/video.m3u8');
hls.attachMedia(video);
const analytics = new TeyutoHlsJsAdapter('your-channel-public', 'user-token');
analytics.init(hls, 'video-id');
// Clean up
window.addEventListener('beforeunload', () => {
analytics.destroy();
hls.destroy();
});
import { TeyutoPlyrAdapter } from 'teyuto-player-analytics';
const player = new Plyr('#player');
const analytics = new TeyutoPlyrAdapter('your-channel-public', 'user-token');
analytics.init(player, 'video-id');
// Clean up
window.addEventListener('beforeunload', () => {
analytics.destroy();
player.destroy();
});
import { TeyutoShakaPlayerAdapter } from 'teyuto-player-analytics';
const video = document.getElementById('video');
const player = new shaka.Player(video);
const analytics = new TeyutoShakaPlayerAdapter('your-channel-public', 'user-token');
analytics.init(player, 'video-id');
// Clean up
window.addEventListener('beforeunload', () => {
analytics.destroy();
player.destroy();
});
When using the SDK via a script tag, all adapters are available under the global TeyutoPlayerAnalytics
object.
<script src="path/to/TeyutoPlayerAnalytics.js"></script>
<script>
const player = videojs('my-video');
const analytics = new TeyutoPlayerAnalytics.TeyutoVideoJsAdapter('your-channel-public', 'user-token');
analytics.init(player, 'video-id');
// Clean up
window.addEventListener('beforeunload', () => {
analytics.destroy();
player.dispose();
});
</script>
<script src="path/to/TeyutoPlayerAnalytics.js"></script>
<script>
const video = document.getElementById('video');
const hls = new Hls();
hls.loadSource('https://example.com/video.m3u8');
hls.attachMedia(video);
const analytics = new TeyutoPlayerAnalytics.TeyutoHlsJsAdapter('your-channel-public', 'user-token');
analytics.init(hls, 'video-id');
// Clean up
window.addEventListener('beforeunload', () => {
analytics.destroy();
hls.destroy();
});
</script>
<script src="path/to/TeyutoPlayerAnalytics.js"></script>
<script>
const player = new Plyr('#player');
const analytics = new TeyutoPlayerAnalytics.TeyutoPlyrAdapter('your-channel-public', 'user-token');
analytics.init(player, 'video-id');
// Clean up
window.addEventListener('beforeunload', () => {
analytics.destroy();
player.destroy();
});
</script>
<script src="path/to/TeyutoPlayerAnalytics.js"></script>
<script>
const video = document.getElementById('video');
const player = new shaka.Player(video);
const analytics = new TeyutoPlayerAnalytics.TeyutoShakaPlayerAdapter('your-channel-public', 'user-token');
analytics.init(player, 'video-id');
// Clean up
window.addEventListener('beforeunload', () => {
analytics.destroy();
player.destroy();
});
</script>
All adapters (TeyutoVideoJsAdapter, TeyutoHlsJsAdapter, TeyutoPlyrAdapter, and TeyutoShakaPlayerAdapter) have the following methods:
-
constructor(channel, token)
: Initialize with your channel (required) and user token (optional). -
init(player, videoId)
: Start tracking for a specific player and video. -
destroy()
: Clean up resources and stop tracking.
- The
channel
parameter is required and represents your Teyuto channel identifier. - The
token
parameter is optional and represents the token of the user you want to track. This allows you to associate the viewing analytics with a specific user in your system. - If you don't provide a token, the analytics will still be tracked, but without user-specific information.
If analytics data isn't appearing:
- Check console for errors.
- Verify that you've provided a valid channel identifier.
- If using user tracking, verify the user token.
- Ensure the video ID is correct.
- Verify that player events (play, pause, ended) are triggering correctly.
For issues or questions, contact Teyuto support at support@teyuto.com or open an issue in this repository.