Google analytics API v4 max results

喜你入骨 提交于 2019-12-23 12:35:35

问题


Can someone please help me for Google analytic API V4: how to pass: max-result parameter with this class: Google_Service_AnalyticsReporting I am unable to find relevant function to assign max-result parameter value.


回答1:


Based on https://stackoverflow.com/a/38922925/1224827 , the parameter you're looking for is pageSize:

The correct name of the parameter you are looking for is: pageSize. The Reference Docs provide the full API specifications.

def get_report(analytics):
  # Use the Analytics Service Object to query the Analytics Reporting API V4.
  return analytics.reports().batchGet(
      body={
        'reportRequests': [
        {
          'viewId': VIEW_ID,
          'pageSize': 10000,
          'dateRanges': [{'startDate': '2016-04-01', 'endDate': '2016-08-09'}],
          'dimensions': [{'name':'ga:date'},
                    {'name': 'ga:channelGrouping'}],
          'metrics': [{'expression': 'ga:sessions'},
                 {'expression': 'ga:newUsers'},
                 {'expression': 'ga:goal15Completions'},
                 {'expression': 'ga:goal9Completions'},
                 {'expression': 'ga:goal10Completions'}]
        }]
      }
  ).execute()

Note: the API returns a maximum of 100,000 rows per request, no matter how many you ask for (according to the documentation). As you attempted max_results this tells me you are trying to migrate from the Core Reporting API V3, check out the Migration Guide - Pagination documentation to understand how to request the next 100,000 rows.

Stack Overflow extra tip. Include your error responses in your question, as it will likely improve your chances of someone being able to help.




回答2:


You can use parameter page_size: 10000. Hope this helps.



来源:https://stackoverflow.com/questions/43657140/google-analytics-api-v4-max-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!