Reputation: 47
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
Upvotes: 0
Views: 1811
Reputation: 77
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']
}]
}]
}]
Upvotes: 3