1

I am pulling data programmatically from google analytics. This is the query I execute

  def executeDataQuery(analytics: Analytics, profileId: String) : GaData = {
    analytics.data().ga().get("ga:" + profileId,
      "2012-01-01", // Start date.
      "2012-01-14", // End date.
      "ga:visits") // Metrics.
      .setDimensions("ga:date")
      .setSort("ga:date")    
      .setMaxResults(25)     
      .execute()
  }

This gives visits/day. I assume the default granularity is per day.

How can I change the granularity of the data from visits/day to visits/minute or visits/month? I know this can be done on the google analytics website.

4

1 回答 1

4

使用Core Reporting API Time-Dimensions & Metrics可以通过多种方式分割数据。

例如,如果您想将其更改为小时,您可以这样做:

.setDimensions("ga:dateHour")

如果您想预览 api 可以获得的数据,请使用GA Query Explorer

于 2013-10-18T16:29:13.150 回答