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" } ] }}