Explore Viewer Engagement
The Livepeer Studio Dashboard is a frontend interface for publishing live or on-demand video streams with no code. In this guide, we'll show you how to use the dashboard to retrieve viewership metrics.
Step 1: Navigate to the Assets page (opens in a new tab)
Step 2: Click on an existing asset
Click on an existing asset and you'll be brought to that asset's specific details page. If you haven't created an asset yet, you can follow the upload a video asset guide.
Step 3: View your asset's viewership metrics
In the asset's specific detail page you can view its total number of views.
The viewership API is still in development. Currently, viewer count metrics are only available for on demand assets. The count registers start views with deduping logic that prevents users from attempting to inflate view counts. In the future, we'll support additional viewership and engagement metrics so you can better understand popularity and performance.
Using the Livepeer Player
Step 1: Register viewership metrics
To collect and register viewership metrics, you first need to configure your player. We recommend that you use the Livepeer player to get viewership metrics, as it comes fully configured. You can follow the Player guide to get started.
Step 2: Get the asset.id
of an existing asset
Get the asset.id
of an existing asset. An asset.id
can be found in the
response object of any API call working with assets. If you haven't created an
asset yet, you can follow the
upload a video asset guide.
Step 3: Retrieve viewership data
Once you have the asset.id
, you can make a request to get the viewership data.
const response = await fetch(
'https://livepeer.studio/api/data/views/{assetId}/total',
{
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.API_TOKEN}`,
},
},
);
const { startViews } = (await response.json())[0];
Using a Custom Player
Step 1: Register viewership metrics
We also support viewership metrics for applications using custom players.
In order for metrics to be tracked by Livepeer, you will need to configure
your player using addMediaMetrics
.
Here's how to configure your player:
import { addMediaMetrics } from 'livepeer/media/browser';
const source =
'https://livepeercdn.studio/recordings/bd600224-d93a-4ddc-a6ac-2d71e3c36768/index.m3u8';
const video = document.getElementById('my-video');
// set up your player before calling addMediaMetrics
addMediaMetrics(video, source, (e) => console.error('Error adding metrics', e));
import { addMediaMetrics } from 'livepeer/media/browser';
const source =
'https://livepeercdn.studio/recordings/bd600224-d93a-4ddc-a6ac-2d71e3c36768/index.m3u8';
const video = document.getElementById('my-video');
// setup your player before calling addMediaMetrics
addMediaMetrics(video, source, (e) => console.error('Error adding metrics', e));
Step 2: Get the asset.id
of an existing asset
Get the asset.id
of an existing asset. An asset.id
can be found in the
response object of any API call working with assets. If you haven't created an
asset yet, you can follow the upload a video asset guide.
Step 3: Retrieve viewership data
Once you have the asset.id
, you can make a request to get the viewership data.
const response = await fetch(
'https://livepeer.studio/api/data/views/{assetId}/total',
{
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.API_TOKEN}`,
},
},
);
const { startViews } = (await response.json())[0];