Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

How to Retrieve Impressions Metric from YouTube Analytics API?

$
0
0

I'm working on a project where I need to retrieve impression metrics for YouTube videos using the YouTube Analytics API. I've tried querying the API with the reports.query() method and specifying the 'impressions' metric, but I'm not getting the expected results. Can anyone provide guidance on how to correctly fetch impression data for YouTube videos?

I have tried this query

$client = new \Google\Client();$client->setApplicationName('Social Media');$client->setAccessToken($account_access_token);$youtubeService = new \Google_Service_YouTubeAnalytics($client);$youtubeAnalyticsImpression = $youtubeService->reports->query(["ids" => 'channel=='.$username,'dimensions' => 'video','startDate' => '2006-01-01','endDate' => Carbon::now()->year . '-12-31','metrics' => 'impressions','filters' => 'video==' . $video_id,]);

But get error

{"error": {"code": 400,"message": "Unknown identifier (impressions) given in field parameters.metrics.","errors": [      {"message": "Unknown identifier (impressions) given in field parameters.metrics.","domain": "global","reason": "invalid"      }    ]  }}

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>