Analytics

Analytics

The Analytics API provides detailed video viewing data including watch time, viewer information, device details, and geographic data.

Base URL

example
https://stats.dyntube.com/v1
Note: Analytics uses a different base URL than other API endpoints.

Available Endpoints

Method / Endpoint / Description
MethodEndpointDescription
POST/logs/dataGet video analytics data

Analytics Data

Each view record includes:

  • Video Information: Video key, project, channel
  • Viewer Details: Viewer ID, custom user ID
  • Watch Data: Duration, watch time, started/ended status
  • Device Info: Browser, device type, operating system
  • Geographic Data: IP, city, country, region, continent
  • Embed Info: URL, domain where video was embedded

Custom User Tracking

You can track your own user IDs in analytics by adding data-user-id to the embed code:

html
<div data-user-id="YOUR_USER_ID" data-dyntube-key="VIDEO_KEY"></div>

Quick Example

javascript
// Get analytics data
const response = await fetch('https://stats.dyntube.com/v1/logs/data', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    from: '2024-01-01',
    to: '2024-01-31',
    page: 1,
    size: 20
  })
});

const data = await response.json();
console.log('Total views:', data.Pager.Total);
console.log('Views:', data.Views);

Something missing or wrong here? Tell us and we will correct it. New to DynTube? Start with uploading and embedding.