0

The aim is to extract un-sampled report from Google Analytics Account(Premium account) using the management api.

I am unable to create report for more than 20 days of data.I am using only one dimension(custom dimension) and one metric(ga:user) as our input parameter.

The API allows us to trigger a report of only 20 days beyond this error is thrown -> "error code :400 Request too expensive to be fulfilled".

Please find the code below.

    $unsampledReport = new Google_Service_Analytics_UnsampledReport();
    $unsampledReport['start-date'] = '2017-09-01';
    $unsampledReport['end-date'] = '2017-12-30';
    $unsampledReport->setMetrics('ga:pageviews');
    $unsampledReport->setDimensions('ga:contentGroup4');
    $unsampledReport->setDownloadType('GOOGLE_DRIVE');
    $report_insert = $analytics->management_unsampledReports- 
    >insert('account_id','property_id,'view_id',$unsampledReport);

This the error being displayed.

> {   "code": 400,   "errors": [
>     {
>       "domain": "global",
>       "message": "Request is too expensive to fulfill.\nTo learn more about Unsampled Reports please see 
> <a  href = "https://support.google.com/analytics/answer/2601061">Ans</a>
}

1 Answers1

1

The error message itself tells you exactly what the problem is.

Request is too expensive to fulfill.

If you check the website in question Unsampled Reports you will see that unsampled reports are very expensive and there are limitations to what you can extract.

I would try only selecting for a week at a time. it should improve your changes for extracting the data you need.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • yes unsampled reports consume tokens according to data size.Even though we have sufficient tokens for that it never creates a report for more than 20 days through API. If we use UI/website it is possible to create for entire year or more – arunav mehrotra May 17 '18 at 10:07
  • Thats not what the error is telling you. The error is telling you that the report is to big for their server to tackle. It has nothing to do with the number of tokens you have left in your quota. Contact your premium account manager you will get direct support from Google for this they will probably tell you the exact same thing i am telling you. – Linda Lawton - DaImTo May 17 '18 at 10:13
  • Thanks . Is there anything that can be done about this because the expected number of rows returned by this is around 30 only. We need the report to be generated for a larger date range , almost an year. If we split it into shorter date range and try to aggregate them afterwards it would cause a huge difference in numbers from the actual numbers(which we are getting by doing a manual generation through website). – arunav mehrotra May 17 '18 at 10:44
  • 1
    @DalmTo is right, Break up the report into multiple requests with shorter date ranges and merge the results locally. You will use more of your tokens but that is better than not getting any data at all. An alternative to Unsampled reports is [BigQuery Export](https://support.google.com/analytics/answer/3437618). – Matt May 18 '18 at 15:21