3

I'm currently getting unpredictable results with the Google search console API when I include multiple dimensions. There are a few different issues that I assume are related. I'll provide an example of each.

First, the number of rows returned changes based on the rowLimit. Before you judge, hear me out. When I make a request with a rowLimit of 5,000, I get 3836 rows. When I decrease the rowLimit to 1000, I get 674 rows. I would obviously expect to get 1000 rows when the rowLimit is 1000.

Here is my test script. I'll exclude the authentication portion since it is clearly working.

def execute_request(service, property_uri, request):
    return service.searchanalytics().query(
            siteUrl=property_uri, body=request).execute()

service = build('webmasters', 'v3', http=http)

site = 'http://www.example.com'

# Request using 5000 rowLimit
request = {
    'startDate': '2017-03-19',
    'endDate': '2017-03-19',
    'dimensions': ['query', 'page', 'country', 'device'],
    'rowLimit': 5000
}
results = execute_request(service, site, request)

print request
print 'total number of rows', len(results.get('rows', []))

# Request using 1000 rowLimit
request = {
    'startDate': '2017-03-19',
    'endDate': '2017-03-19',
    'dimensions': ['query', 'page', 'country', 'device'],
    'rowLimit': 1000
}
results = execute_request(service, site, request)

print request
print 'total number of rows', len(results.get('rows', []))

This prints:

{'startDate': '2017-03-19', 'endDate': '2017-03-19', 'dimensions' ['query', 'page', 'country', 'device'], 'rowLimit': 5000}
total number of rows 3836
{'startDate': '2017-03-19', 'endDate': '2017-03-19', 'dimensions': ['query', 'page', 'country', 'device'], 'rowLimit': 1000}
total number of rows 674

The next issue is likely related. I would expect that when I increase the number of dimensions - increasingly granularity - more rows would be available, not less.

Keeping a fixed rowLimit of 5000, if I make a request including one dimension, I get 4988 results. When I include all four dimensions, I get 3836 rows. I would expect to get at least as many rows when including more dimensions.

For the sake of brevity, I won't include the test script I used for this test. It's nearly identical to the one from above. But I will include the results so you can see the request and the number of rows returned.

{'startDate': '2017-03-19', 'endDate': '2017-03-19', 'dimensions': ['page'], 'rowLimit': 5000}
total number of rows 4988
{'startDate': '2017-03-19', 'endDate': '2017-03-19', 'dimensions': ['query', 'page', 'country', 'device'], 'rowLimit': 5000}
total number of rows 3836

It would be helpful to know if I'm doing something wrong, or if this appears to be a bug with the API. Thanks in advance.

Tyler Jones
  • 123
  • 7

0 Answers0