YouTube Analytics API

YouTube Analytics API vs YouTube Reporting API

Not sure which of the YouTube APIs is right for you? Lets breakdown the similarities and differences:
YouTube Analytics API
  • Supports real-time queries to generate custom analytics reports
  • Supports filtering and sorting the query
  • Allows a date range to be specified
  • Allows weekly or monthly intervals to be returned
  • Returns the data as a response to the request
YouTube Reporting API
  • Does not have native filtering and designed to bulk download large data sets
  • Offers various reports each with a predefined set of fields
  • Reports are scheduled and then asynchronously downloaded
  • Allows some owners programmatic access to ad revenue data
Similarities
  • Both allow you to report on a channel or an owner (all channels)
  • Require authorization by the channel or content owner
  • Use OAuth to authenticate

Want to Export or Sync YouTube Data from the API

If you don’t want to call the API directly and just want the data sync’d to your data platform of choice SyncWith does this for 100,000s of users and businesses:
notion image
  • Youtube API to Databases (S3, BigQuery, MySQL, Postgres) - contact support to join our beta

YouTube Analytics API

If you’re interested in calling the YouTube Analytics API than you the idea of creating a custom query is useful to you.
Lets take a look at the dimensions, metrics and filters you can apply to a query and then how to craft a query to send to Google.

Dimensions

  • ageGroup - Allows you to better understand the age demographics of you’re YouTube suers
  • channel - Lets you break out the metrics by channel
  • country - Break out the metrics by Country, eg United States, Canada
  • day - Breaks the metrics out by day allowing you to see daily trends
  • month - Breaks out by month which is great for longer term reporting or where you’ve selected multiple dimensions and need to aggregate the metrics over a longer period
  • sharingService - breaks out by the service used to share the videos, eg:
    • ANDROID_EMAIL - Android email
    • LINKEDIN - LinkedIn
    • Etc
  • uploaderType - Breaks out metrics between self and thirdParty - useful if you want to see how third party contributors are performing as a whole
  • video - Critical if you want to get metrics specific to certain videos

Metrics

The YouTube Analytics API Metrics is very comprehensive.
The Metrics are grouped into 9 areas:
  • Core metrics (some repeat below)
    • Average view duration
    • Comments
    • Likes
    • Dislikes
    • Estimated revenue
    • Shares
    • Views
    • Viewer percentage
    • Subscribers lost
    • Subscribers gained
    • Estimated minutes watched
    • Annotations close rate
    • Annotations click through rate
  • View metrics
    • Views
    • Red views
    • uniques
  • Watch time metrics
    • Estimated minutes watched
    • Estimated red minutes watched
    • Average view duration
  • Engagement metrics
    • comments
    • likes
    • dislikes
    • shares
    • Subscribers gained
    • Subscribers lost
    • Videos added to playlists
    • Videos removed from playlists
  • Playlist metrics
    • Playlist starts
    • Views per playlist start
    • Average time in playlist
  • Annotations metrics
    • Annotation impressions
    • Annotation clickable impressions
    • Annotation clicks
    • Annotation click through rate
    • Annotation closable impressions
    • Annotation closes
    • Annotation close rate
  • Card metrics
    • Card impressions
    • Card clicks
    • Card click rate
    • Card teaser impressions
    • Card teaser clicks
    • Card teaser click rate
  • Audience retention metrics
    • Audience watch ratio
    • Relative retention performance
  • Estimated revenue metrics
    • Estimated revenue
    • Estimated ad revenue
    • Estimated red partner revenue
  • Ad performance metrics
    • Gross revenue
    • CPM
    • Ad impressions
    • Monetized playbacks
    • Playback based CPM

Creating a API Request to YouTube

  • Send a Request to the endpoint https://youtubeanalytics.googleapis.com/v2/reports
  • Authenticate via OAuth
  • Set query parameters:
    • startDate - to set the first day of data you want reported on. Use the form YYYY-MM-DD
    • endDate - to set the last day of data you want reported on. Use the form YYYY-MM-DD
    • dimensions - to provide a comma separated list of dimensions you’d like eg video,month,ageGroup
    • metrics - to provide a comma separated list of metrics you’l like eg comments,likes,dislikes,views
Pulling it all together if we wanted to get the last 30 days, not including the current day (assuming today is Jul 31, 2021) and we wanted to report on engagement by gender by video we’d specify the following query:
https://youtubeanalytics.googleapis.com/v2/reports?startDate=2021-07-01&endDate=2021-07-30&dimensions=video,gender&metrics=comments,likes,dislikes,shares,subscribersGained,subscribersLost

Related Tutorials

Get YouTube video views by traffic source type

Drill into the number of views each of your videos gets by the source of the traffic, for example advertising, external links and embeds.

YouTube Analytics in Google Sheets

The YouTube Analytics API lets you pull analytics data into Google Sheets to automate complex reporting tasks, build custom dashboards and more. You can pull data about a video channel, to find out key metrics including views, comments, likes, minutes watched, view duration, subscribers gained or lost, and you can segment it by video, or by time period such as day, week, month etc.