1

I am extracting Search Analytics data for some Property using search console API v3. I am using googleapiclient library(Python) for making API call. Python script making API request:

from googleapiclient import sample_tools

service, flags = sample_tools.init(['https://example.com/'], 'webmasters', 'v3', __doc__, __file__,
                                             # parents=[argparser],
                                              scope='https://www.googleapis.com/auth/webmasters.readonly')

rowlimit = 5000      #initialised variable to pass values of rowLimit and startRow
startrow = 0

request = {
               'startDate': '2017-05-10',
               'endDate': '2017-05-10',
               'dimensions': ['date','query'],
               'rowLimit': rowlimit,
               'aggregationType': 'byProperty',
               'startRow': startrow
}

response = execute_request(service, 'https://example.com/', request)

We are getting response. Now there is one limitation that we can not give rowLimit > 5000.

Now with each request we often don't get 5000 records. So for next iteration I am setting startRow value by record beyond what I got in first request.

i.e. startrow = startrow+record_count_in_first_request So, second iteration will have startRow:startrow
rowLimit:5000

Using this approach I can get all the result data for certain date range.

But now I am facing another issue. The metrics values that I extracted using API are not matching with console platform(UI) values.
I checked the sum of clicks, impression over a certain date range, it is not matching with UI values for same date range. Why do you think that happens?

Again this is the case when I use 'dimensions': ['date', 'query'] on the other hand when I use 'dimensions': ['date', 'page'] then I am getting correct result. I have checked the results with console UI. This behaviour of console search API is quite confusing. Does anybody faced similar issue before. Is there any sampling of data? Let me know if you need more information regarding the issue I am facing. Thanks for you time.

Subhash Deshmukh
  • 350
  • 3
  • 18
  • why are you using 'dimensions':['date', 'query'] when your startDate and endDate are the same? putting 'date' in the 'dimensions' is redundant...you should just use 'dimensions':['query'] – eyedar Aug 04 '17 at 20:25

1 Answers1

1

In short, when you use page in dimensions and you didn't specify aggregationType in your API call, then the aggregation type will be determined by the API service.

aggregationType determines how clicks and impressions are aggregated. When you use dimensions: date, query, the API will use byProperty aggregation type by default while date, page automatically choose byPage type. It is documented here.

Please have a read on this documentation for the difference between byProperty (or site) and byPage.

baxang
  • 3,627
  • 1
  • 29
  • 27
  • 1
    Yes, I have read about the aggregationType and how it affects the clicks and impressions aggregation. I also observed that for some queries google does not provide any data. One more thing I observed that from UI export we can not get more that 1000 queries(rows). So we will never match it with the data pulled using API exactly. Let me know if you have more suggestions. Thanks – Subhash Deshmukh Jul 05 '17 at 06:50