You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在YouTube Analytics API请求中添加视频维度获取视频级流量数据

Adding Video Dimension to YouTube Analytics API Request for Video-Level Traffic Source Data

Got it, let's adjust your existing API call to pull video-level traffic source metrics easily. Here's the modified request you can use:

https://www.googleapis.com/youtube/analytics/v1/reports?ids=channel==[ChannelID]&start-date=[STARTDATE]&end-date=[ENDDATE]&metrics=views,estimatedMinutesWatched&dimensions=day,insightTrafficSourceType,video&filters=country==US&include-historical-channel-data=true&max-results=10000

Key Changes & Notes:

  • Added video to the dimensions parameter: This is the core tweak—by including video alongside day and insightTrafficSourceType, the API will break down metrics per individual video, per day, per traffic source.
  • Increased max-results to 10000: Video-level data generates far more rows than channel-level, so bumping this up (the maximum allowed value is 10000) helps avoid truncating results. If you need more than 10000 rows, you'll have to implement pagination using the nextPageToken from the response.
  • Permissions Check: Ensure your OAuth 2.0 token has the youtubeAnalytics.readonly scope (and optionally youtube.readonly if you want to map video IDs to titles later)—this is required to access video-level analytics data.
  • Data Output: The response will now include a video column with the video ID, letting you correlate each row's views and watch time to a specific video, its traffic source, and the day it was recorded.

If you run into issues like dimension/metric incompatibility (though this combination is valid per YouTube Analytics specs), double-check that your date range doesn't include videos that might have been removed, or verify your channel ID is formatted correctly.

内容的提问来源于stack exchange,提问作者R P

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 09:05:18