https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/reports/batchGet
This gist is for doing some batch query testing against GA. The data we need is:
Page level
- pageviews, users, newUsers =>
pageview-query.js
setting
pageSizeto100to get thenextPageTokenin the response users = "The total number of users for the requested time period" newUsers = "The number of sessions marked as a user's first sessions"
- downloads =>
download_query.js
setting
pageSizeto100to get thenextPageTokenin the response
Hoping we can filter on the eventCategory or eventAction so we can do more targeted querying
Site level
- users, newUsers =>
sitewide-query.js
setting
pageSizeto100to get thenextPageTokenin the response
- unique_visitors
- returning_visitors
- We can set the
pageSizeup to10000 - Any additional results not returned can be accessed by sending another query using the
nextPageTokenfrom the response as thepageTokenin the next request
- Can we get pageviews, visitors (both types) and downloads back in a single query? Probably not downloads.. but worth a shot. Maybe if we send downloads as a virtual pageview??
- How do we calculate "unique_visitors" and "returning_visitors" from the GA metrics
newUsersandusers?? unique_visitors==users?returning_visitors==users - newUsers?