简体   繁体   中英

get a report of the last 7 days divided by day with google analytics reporting api

i need to build retrive data devided by day for build a graph of the last 7 days.

following this guide: https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/web-js

dateRanges[] only accept two range.

can you help me?

sorry for my bad english... not my native language

1. You should be adding ga:date in your dimension array. It's good to know that by doing this you won't be doing as many request you would be doing by looping thru a dateRange yourself, this way the DateRangeObject will hold only values for the dates that fall within the respective ranges.

2. Supposing that you are trying to get back the page-views of certain pagePath day by day.

Your reportRequest should be something like this:

'reportRequests': [
            {
                'viewId': VIEW_ID,
                'dateRanges': [{'startDate': '2019-02-13', 'endDate': '2019-02-15'}],
                'metrics': [{'expression': 'ga:pageviews'}],
                'samplingLevel': 'SMALL',
                'dimensions': [{'name': 'ga:pagePath'}, {'name': 'ga:date'}],
                'dimensionFilterClauses': [{
                    'filters': [{
                        'dimensionName': 'ga:pagePath',
                        'operator': 'EXACT',
                        'expressions': ['SomeExpression']
                    }]
                }]
            }]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM