Get Analytics
get_analyticsYouTube Analytics for your channel: totals, or rows broken down by one dimension.
Instructions
YouTube Analytics for your channel: totals, or rows broken down by one dimension.
Data for the last two or three days is incomplete, so recent rows keep growing. Uses the separate YouTube Analytics API and its quota; enable it in the same Google Cloud project.
Quota: no YouTube Data API units.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | No | Break the numbers down by this dimension; its column is named as given here. Omit for totals. By month, the range widens to whole months. By elapsed: the audience retention of exactly one video, a row per 1% of its length (0.01 to 1). By traffic-source-detail, which needs traffic_source: the search terms behind YT_SEARCH, the videos behind RELATED_VIDEO, the sites behind EXT_URL. | |
| sort | No | Metric or dimension to sort by; prefix with - for descending, e.g. -views. Defaults to chronological by day, month or elapsed, and to the first metric, descending, by anything else. | |
| limit | No | Maximum number of rows. Breaking down by video returns at most 200, 25 by default; by traffic-source-detail, at most 25. Other breakdowns return every row by default. | |
| since | No | First day, inclusive: 2026-01-01, or 90d / 4w before until. Defaults to 28 days before until. | |
| until | No | Last day, inclusive: 2026-01-31, or 7d / 1w ago. Defaults to today. | |
| videos | No | Only these videos (IDs or URLs). | |
| country | No | Only viewers in this country, e.g. US. Not by elapsed. | |
| metrics | No | Metric names from https://developers.google.com/youtube/analytics/metrics, e.g. views, estimatedMinutesWatched, subscribersGained. Defaults to views, watch time, average view duration, likes, comments, and subscribers gained and lost. By device, os, traffic-source, playback-location or subscribed, only watch metrics work (views, estimatedMinutesWatched, averageViewDuration, averageViewPercentage), and those are the default. By age or gender, only viewerPercentage works. By elapsed: audienceWatchRatio (share of viewers watching at that point, above 1 with rewatches) and relativeRetentionPerformance (0 to 1, against videos of similar length) by default, or startedWatching and stoppedWatching. By traffic-source-detail: views and estimatedMinutesWatched. By sharing-service: shares. | |
| my_channel | No | Which of your logged-in channels to work on: UC… ID, @handle or exact title. Omit for the default channel. | |
| content_type | No | Only long-form videos (videoOnDemand), shorts, or live streams (liveStream), as the content-type breakdown names them. Not by elapsed. | |
| traffic_source | No | The source to break down by traffic-source-detail, as the traffic-source breakdown names it, e.g. YT_SEARCH. Only with that breakdown. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rows | Yes | ||
| since | Yes | ||
| until | Yes | ||
| columns | Yes | Dimension first (if any), then the metrics, in request order. |