Livepeer offers detailed information on viewer behavior and playback quality on your platform. The API includes engagement metrics such as view counts and watch time, as well as performance metrics such as error rate, time to first frame, rebuffer ratio, and exit-before-starts across a variety of dimensions.

Usage Metrics

This API also includes usage metrics to help you understand how viewers are engaging with your platform:

  • Number of Views: This metric gives you a comprehensive view of the total number of views across your platform. We colloquially define a view as “play intent”, which means the video either played, stalled, or encountered an error.
  • Minutes of Watch Time: Measure the total amount of time viewers spend on your platform, so you can track engagement and identify areas for improvement.

Performance Metrics

This API offers several key performance metrics to help you understand your platforms performance:

  • Error Rate: Percentage of views that encountered an error.
  • Time to First Frame (TTFF): Measures the time in milliseconds it takes between the player requesting video and the first frame being ready to play.
  • Rebuffer Ratio: Percentage of time a viewer spends experiencing rebuffering during playback.
  • Exit Before Starts: Percentage of views that are abandoned before the video begins to play, potentially indicating issues with playback.

Dimensions

To provide a comprehensive view of viewer behavior, our data product includes several dimensions to help you segment your data and identify patterns:

  • Video: View metrics for individual videos, queryable by playback ID or by dStorage ID’s, such as CID.
  • Browser: Understand how different browsers impact viewer behavior and performance, so you can optimize your platform for each browser type.
  • Device: Understand how different devices impact viewer behavior, so you can optimize your platform for each device type.
  • OS: Understand how different operating systems impact viewer behavior, so you can optimize your platform for each OS.
  • Continent, Country, and Subdivisions: Segment your data by location to identify regional trends and tailor your platform to local preferences.
  • Time Zone: Measure viewer behavior across different time zones, so you can optimize your platform for peak usage times.
  • Time: Analyze viewer behavior across different time periods (hour, day, week, month, year, all-time) to identify trends.

Please note that data is refreshed every 5 minutes and newly uploaded videos may take up to an hour before viewership data is available

Registering views

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.

Retrieving views from the Dashboard

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.

Assets page

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.

Assets page

View your asset’s viewership metrics

In the asset’s specific detail page you can view its total number of views.

Asset views

Retrieving views from the API

Get the playbackId of an existing asset

Get the playbackId of an existing asset. A playbackId can be found in the asset page on the dashboard or from any Asset API call. If you haven’t created an asset yet, you can follow the upload a video asset guide.

The playbackId can be a canonical playback ID from a specific Livepeer asset or stream objects, or dStorage identifiers for assets. Queries by dStorage ID are universal/cross-account, as explained below, so check what makes the most sense for your app.

When querying by dStorage ID (e.g. ipfs:// or ar:// URLs, or CID/txID), you will get views for all assets with that dStorage ID across any Livepeer account. This is useful to display global metrics from a video. To display the viewership metrics only from the videos in your account, use the API objects playbackId.

Retrieve viewership data

Once you have the playbackId, you can make a request to get the viewership data.

import { Livepeer } from "livepeer";

const apiToken = 'YOUR_API_TOKEN';
const playbackId = 'PLAYBACK_ID';

const livepeer = new Livepeer(apiToken);

livepeer
  .getTotalViews(playbackId)
  .then((response) => {
    console.log("Total views:", response);
  })
  .catch((error) => {
    console.error("Error fetching total views:", error);
  });

For more information on the API used here check the API reference.

Diving deeper

If you’re happy with the above metrics you can stop here. If you want to build more advanced analytics, you can use the following API endpoints to get more detailed data.

Creator metrics API

This API can be called from the frontend to retrieve detailed engagement metrics for a specific resource. The only restriction it has is that it has to be called with an assetId or streamId values, which are private values today that only the asset creator should have access. Soon this creator ownership will be validated using wallet signatures instead.

The idea for this API is to build creator analytics dashboards. It can be called from the frontend and can provide detailed insights to creators about their assets and streams.

import { Livepeer } from "livepeer";

const apiToken = 'YOUR_API_TOKEN';
const assetId = 'ASSET_ID';
const timeStep = 'day';
const breakdownBy = ['timezone'];

const livepeer = new Livepeer(apiToken);

const queryParams = {
  assetId: assetId,
  timeStep: timeStep,
  breakdownBy: breakdownBy
};

livepeer
  .getViewsByCreator(queryParams)
  .then((response) => {
    console.log("Views by creator:", response);
  })
  .catch((error) => {
    console.error("Error fetching views by creator:", error);
  });

All metrics API

This API can be called from the backend to retrieve detailed engagement metrics for a specific resource. It requires a non-CORS API key to be used, meaning that it cannot be called from the frontend. This is for security reasons since this API provides full access to all metrics in the account, meaning it provides the most flexibility in queries.

The idea is that developers should build their own abstraction and access control logics on top of this API and abstract it as higher level API in their apps.

import { Livepeer } from "livepeer";

const apiToken = 'YOUR_API_TOKEN';
const breakdownBy = ['device', 'browser']; // Define the breakdown criteria

const livepeer = new Livepeer(apiToken);

const queryParams = {
  breakdownBy: breakdownBy
};

livepeer
  .getViews(queryParams)
  .then((response) => {
    console.log("Views:", response);
  })
  .catch((error) => {
    console.error("Error fetching views:", error);
  });

Visualizing Your Data

If you are ready to take a deep dive into your data, then visualizations are the next step. We have put together a tutorial complete with templates to get you started.

Visualize Engagement Metrics with Grafana

If you are interested in visualizing your engagement metrics with Grafana, feel free to check out our tutorial, Visualize Engagement Metrics with Grafana, to learn more.