Kitler Kitler - 2 months ago 16x
PHP Question

Youtube Analytics API Demographic dimension "gender" shows on analytics dashboard but gives query invalid on API Explorer

I am currently working with the Youtube Analytics API,

So far i have been able to pull all the data that youtube has to offer except the gender/ageGroup dimensions the query fails everytime,

The docs point to examples to playbacklocation and not the demographic it's self.

I am using the PHP Client Library,

== PHP ==

$analytics_gender = new Google_YouTubeAnalyticsService($client);

$optparam = array('dimensions' => 'gender');

$metrics= "views";

$analytics_demo_gender = $analytics_gender->reports->query("channel==".$channelId, "2012-08-14", "2013-05-30", $metrics, $optparam);

When i run this query i get an
error (400) The query is not supported.
even though it works just fine for all the other metrics and dimensions.


The gender dimension can only be used with the metric viewerPercentage (and optionally with a country and/or video filter and with an additional ageGroup dimension, if you'd like). You can search the relevant documentation for "gender" to see the exact specifications.

Here's an example of a working report in the API Explorer. Authenticate, and replace CHANNEL_ID with the id of your channel.