arunav mehrotra
arunav mehrotra

Reputation: 11

Initiate un-sampled reports creation in google analytics using Management API

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

Upvotes: 0

Views: 281

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 117291

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.

Upvotes: 1

Related Questions