I am setting up a reporting script which gets data from google analytics .I am adding three dimensions to get the data but one of the those dimensions is custom dimension named test_dimension. When i set this dimension i get this error.
Unknown dimension(s): test_dimension
I tried the developer API but cannot get the expected results https://developers.google.com/analytics/devguides/reporting/core/dimsmets#view=detail&group=custom_variables_or_columns&jump=ga_dimensionxx
$custom = new Google_Service_AnalyticsReporting_Dimension();
$custom->setName("test_dimension");
$campaign = new Google_Service_AnalyticsReporting_Dimension();
$campaign->setName("ga:campaign");
$sourceMedium = new Google_Service_AnalyticsReporting_Dimension();
$sourceMedium->setName("ga:sourceMedium");
$request->setDimensions(array($custom,$campaign,$sourceMedium));
$body = new Google_Service_AnalyticsReporting_GetReportsRequest();
$body->setReportRequests( array( $request) );
return $analytics->reports->batchGet( $body );
I expect the output with the applied dimensions. If i remove the custom dimension the code works.