My Business
3.9K members online now
3.9K members online now
For developers who are using the Google My Business API to manage locations
Guide Me
star_border
Reply

reportInsights endpoint incorrectly returns 0 for day after last available datapoint

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I've really enjoyed working with the reportInsights endpoint to pull metrics for locations, but I've noticed something odd about how the API handles daily aggregates for days on which no data are available.

 

The easiest way to summarize this is "for the day immediately following the last available datapoint, the value is 0, while all subsequent values are undefined".

 

Here's an example. I made a request at 4:45 pm PST for one location. (if account and location names are useful, I can provide them)

 

I specified the "start time" to be the beginning of February and left the "end time" unspecified, the intent being I want all available data up to today (that is, 2017-04-24).

 

The options for my request look like: 

 

opts = {
      method: 'POST',
      json: {
        locationNames: ['LOCATION_NAME_REDACTED'],
        basicRequest: {
          metricRequests: [
            metric: 'ALL',
            options: ['AGGREGATED_DAILY']
          ],
          timeRange: {
            startTime: '2017-02-01T08:00:00.000Z',
endTime: 'DEFAULT TO NOW ISO-FMT' } } }

 

Meanwhile, I know that the available data in the GMB Insights dashboard only goes up to 2/20:Data requested through 2/24 only available up to 2/20Data requested through 2/24 only available up to 2/20

 So when I loop through the responses to see the values for each timestamp on a given metric--say `VIEWS_MAPS`--I expect to see data up to 2/20 and nothing after that:

 

VIEWS_SEARCH = data.metricValues[2]
console.log VIEWS_SEARCH.metric
for {timeDimension, value} in VIEWS_SEARCH.dimensionalValues
  console.log timeDimension.timeRange.startTime, value


Instead, I get a `0` value for 2/21, and 2/22- 2/24 are undefined after that:

2017-02-01T08:00:00Z 120
2017-02-02T08:00:00Z 139
2017-02-03T08:00:00Z 90
2017-02-04T08:00:00Z 195
2017-02-05T08:00:00Z 120
2017-02-06T08:00:00Z 113
2017-02-07T08:00:00Z 144
2017-02-08T08:00:00Z 139
2017-02-09T08:00:00Z 133
2017-02-10T08:00:00Z 139
2017-02-11T08:00:00Z 95
2017-02-12T08:00:00Z 149
2017-02-13T08:00:00Z 152
2017-02-14T08:00:00Z 206
2017-02-15T08:00:00Z 217
2017-02-16T08:00:00Z 103
2017-02-17T08:00:00Z 162
2017-02-18T08:00:00Z 93
2017-02-19T08:00:00Z 342
2017-02-20T08:00:00Z 190
2017-02-21T08:00:00Z 0
2017-02-22T08:00:00Z undefined
2017-02-23T08:00:00Z undefined
2017-02-24T08:00:00Z undefined

 I find this behavior to be problematic: how do I know that 2/21 is not legitimately a 0-value day? Is there a more explicit way to indicate data is not available for a given date?

 

If this is not intentional, perhaps this is actually more a bug report than it is a request for guidance, but I'd still like to know what logic I can use to detect datapoints I should drop when data is not available.

1 Expert replyverified_user

Re: reportInsights endpoint incorrectly returns 0 for day after last available datapoint

Google Employee
# 2
Google Employee

Hi @David P,

 

When you retrieve location insights using the Google My Business API, the timeRange object indicates the range to gather metrics for your location. The maximum range is 18 months and 3 days from the current date. Please note, in some cases the data may still be missing for days close to the request date.

 

Thanks,

The Google My Business API team