Query Failed: 400 Unknown Metric(s)

Hi,


I am receiving the below error:

Query failed: 400 Unknown metric(s): ga:itemrevenue, ga:transactionrevenue, ga:transactions For details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets.


This is odd as we are refreshing queries which have been used for over a year without any issues with the metrics we have selected.


I have attached an example of the query we are using.

xlsx

1 person has this problem
  • Hi everyone,


    and thank you for your patience with this matter. That particular error is coming from Google Analytics API, but so far it's uncertain which end is causing it. 


    Our support team is trying to tackle this issue as we speak and we'll keep you posted every time something new comes up.

    Sincere apologies for the inconvenience in this matter.


    Best,

    -Supermetrics Team

  • Hi, we're getting the same error today. Can you verify on your side?

  • Have there been any updates to this with regards to work arounds or context for why the error is occurring? I just ran into this issue today and can't seem to resolve it.

  • If you look more closely into that documentation you will see that session count is not a metric, it's a dimension. The reason is that you want to be able to do breakdowns of metrics by session count (e.g. "show avg. duration of sessions for users with 3 sessions") and for that you need categorical data.

    Even if you overlook the (not particularly distinctive) column heading in the table of contents (ga:sessionCount is in the "dimensions"-column) the fact that the datatype is a string would be a dead giveaway. Metrics are always numbers. Dimensions are always strings, even if they sometimes look like numbers.

    Same goes for ga:sessionDurationBucket.

    Look at this example from the documentation to see how dimensions are passed into the query via an array that holds optional parameters:

    private function queryCoreReportingApi() {
      $optParams = array(
          'dimensions' => 'ga:source,ga:keyword',
          'sort' => '-ga:sessions,ga:source',
          'filters' => 'ga:medium==organic',
          'max-results' => '25');
    
      return $service->data_ga->get(
          TABLE_ID,
          '2010-01-01',
          '2010-01-15',
          'ga:sessions',
          $optParams);
    }
    

    You'd need to construct a similar $optParams array:

    $optParams = array(
              'dimensions' => 'ga:sessionCount,ga:sessionDurationBucket'
              '); 
    

    and pass it to your query:

    return $analytics->data_ga->get(
           'ga:' . $profileId,
           '30daysAgo',
           'today',
            $optParams,  
           'ga:users,ga:percentNewSessions,ga:bounceRate,ga:pageviews');
    }
    

    and remove the dimensions from the list of metrics.

    Btw. Google has a wonderful documentation page on the difference between dimensions and metrics and how they are used in the reports.

Login or Signup to post a comment