analytics_data_api.proto 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.analytics.data.v1alpha;
  16. import "google/analytics/data/v1alpha/data.proto";
  17. import "google/api/annotations.proto";
  18. import "google/api/client.proto";
  19. import "google/api/field_behavior.proto";
  20. import "google/api/resource.proto";
  21. option go_package = "google.golang.org/genproto/googleapis/analytics/data/v1alpha;data";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "AnalyticsDataApiProto";
  24. option java_package = "com.google.analytics.data.v1alpha";
  25. // Google Analytics reporting data service.
  26. service AlphaAnalyticsData {
  27. option (google.api.default_host) = "analyticsdata.googleapis.com";
  28. option (google.api.oauth_scopes) =
  29. "https://www.googleapis.com/auth/analytics,"
  30. "https://www.googleapis.com/auth/analytics.readonly";
  31. // Returns a customized report of your Google Analytics event data. Reports
  32. // contain statistics derived from data collected by the Google Analytics
  33. // tracking code. The data returned from the API is as a table with columns
  34. // for the requested dimensions and metrics. Metrics are individual
  35. // measurements of user activity on your property, such as active users or
  36. // event count. Dimensions break down metrics across some common criteria,
  37. // such as country or event name.
  38. rpc RunReport(RunReportRequest) returns (RunReportResponse) {
  39. option (google.api.http) = {
  40. post: "/v1alpha:runReport"
  41. body: "*"
  42. };
  43. }
  44. // Returns a customized pivot report of your Google Analytics event data.
  45. // Pivot reports are more advanced and expressive formats than regular
  46. // reports. In a pivot report, dimensions are only visible if they are
  47. // included in a pivot. Multiple pivots can be specified to further dissect
  48. // your data.
  49. rpc RunPivotReport(RunPivotReportRequest) returns (RunPivotReportResponse) {
  50. option (google.api.http) = {
  51. post: "/v1alpha:runPivotReport"
  52. body: "*"
  53. };
  54. }
  55. // Returns multiple reports in a batch. All reports must be for the same
  56. // Entity.
  57. rpc BatchRunReports(BatchRunReportsRequest) returns (BatchRunReportsResponse) {
  58. option (google.api.http) = {
  59. post: "/v1alpha:batchRunReports"
  60. body: "*"
  61. };
  62. }
  63. // Returns multiple pivot reports in a batch. All reports must be for the same
  64. // Entity.
  65. rpc BatchRunPivotReports(BatchRunPivotReportsRequest) returns (BatchRunPivotReportsResponse) {
  66. option (google.api.http) = {
  67. post: "/v1alpha:batchRunPivotReports"
  68. body: "*"
  69. };
  70. }
  71. // Returns metadata for dimensions and metrics available in reporting methods.
  72. // Used to explore the dimensions and metrics. In this method, a Google
  73. // Analytics GA4 Property Identifier is specified in the request, and
  74. // the metadata response includes Custom dimensions and metrics as well as
  75. // Universal metadata.
  76. //
  77. // For example if a custom metric with parameter name `levels_unlocked` is
  78. // registered to a property, the Metadata response will contain
  79. // `customEvent:levels_unlocked`. Universal metadata are dimensions and
  80. // metrics applicable to any property such as `country` and `totalUsers`.
  81. rpc GetMetadata(GetMetadataRequest) returns (Metadata) {
  82. option (google.api.http) = {
  83. get: "/v1alpha/{name=properties/*/metadata}"
  84. };
  85. option (google.api.method_signature) = "name";
  86. }
  87. // The Google Analytics Realtime API returns a customized report of realtime
  88. // event data for your property. These reports show events and usage from the
  89. // last 30 minutes.
  90. rpc RunRealtimeReport(RunRealtimeReportRequest) returns (RunRealtimeReportResponse) {
  91. option (google.api.http) = {
  92. post: "/v1alpha/{property=properties/*}:runRealtimeReport"
  93. body: "*"
  94. };
  95. }
  96. }
  97. // The dimensions and metrics currently accepted in reporting methods.
  98. message Metadata {
  99. option (google.api.resource) = {
  100. type: "analyticsdata.googleapis.com/Metadata"
  101. pattern: "properties/{property}/metadata"
  102. };
  103. // Resource name of this metadata.
  104. string name = 3;
  105. // The dimension descriptions.
  106. repeated DimensionMetadata dimensions = 1;
  107. // The metric descriptions.
  108. repeated MetricMetadata metrics = 2;
  109. }
  110. // The request to generate a report.
  111. message RunReportRequest {
  112. // A property whose events are tracked. Within a batch request, this entity
  113. // should either be unspecified or consistent with the batch-level entity.
  114. Entity entity = 1;
  115. // The dimensions requested and displayed.
  116. repeated Dimension dimensions = 2;
  117. // The metrics requested and displayed.
  118. repeated Metric metrics = 3;
  119. // Date ranges of data to read. If multiple date ranges are requested, each
  120. // response row will contain a zero based date range index. If two date
  121. // ranges overlap, the event data for the overlapping days is included in the
  122. // response rows for both date ranges. In a cohort request, this `dateRanges`
  123. // must be unspecified.
  124. repeated DateRange date_ranges = 4;
  125. // The row count of the start row. The first row is counted as row 0.
  126. //
  127. // To learn more about this pagination parameter, see
  128. // [Pagination](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
  129. int64 offset = 5;
  130. // The number of rows to return. If unspecified, 10 rows are returned. If
  131. // -1, all rows are returned.
  132. //
  133. // To learn more about this pagination parameter, see
  134. // [Pagination](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
  135. int64 limit = 6;
  136. // Aggregation of metrics. Aggregated metric values will be shown in rows
  137. // where the dimension_values are set to "RESERVED_(MetricAggregation)".
  138. repeated MetricAggregation metric_aggregations = 7;
  139. // The filter clause of dimensions. Dimensions must be requested to be used in
  140. // this filter. Metrics cannot be used in this filter.
  141. FilterExpression dimension_filter = 8;
  142. // The filter clause of metrics. Applied at post aggregation phase, similar to
  143. // SQL having-clause. Metrics must be requested to be used in this filter.
  144. // Dimensions cannot be used in this filter.
  145. FilterExpression metric_filter = 9;
  146. // Specifies how rows are ordered in the response.
  147. repeated OrderBy order_bys = 10;
  148. // A currency code in ISO4217 format, such as "AED", "USD", "JPY".
  149. // If the field is empty, the report uses the entity's default currency.
  150. string currency_code = 11;
  151. // Cohort group associated with this request. If there is a cohort group
  152. // in the request the 'cohort' dimension must be present.
  153. CohortSpec cohort_spec = 12;
  154. // If false or unspecified, each row with all metrics equal to 0 will not be
  155. // returned. If true, these rows will be returned if they are not separately
  156. // removed by a filter.
  157. bool keep_empty_rows = 13;
  158. // Toggles whether to return the current state of this Analytics Property's
  159. // quota. Quota is returned in [PropertyQuota](#PropertyQuota).
  160. bool return_property_quota = 14;
  161. }
  162. // The response report table corresponding to a request.
  163. message RunReportResponse {
  164. // Describes dimension columns. The number of DimensionHeaders and ordering of
  165. // DimensionHeaders matches the dimensions present in rows.
  166. repeated DimensionHeader dimension_headers = 11;
  167. // Describes metric columns. The number of MetricHeaders and ordering of
  168. // MetricHeaders matches the metrics present in rows.
  169. repeated MetricHeader metric_headers = 1;
  170. // Rows of dimension value combinations and metric values in the report.
  171. repeated Row rows = 2;
  172. // If requested, the totaled values of metrics.
  173. repeated Row totals = 8;
  174. // If requested, the maximum values of metrics.
  175. repeated Row maximums = 9;
  176. // If requested, the minimum values of metrics.
  177. repeated Row minimums = 10;
  178. // The total number of rows in the query result, regardless of the number of
  179. // rows returned in the response. For example if a query returns 175 rows and
  180. // includes limit = 50 in the API request, the response will contain row_count
  181. // = 175 but only 50 rows.
  182. //
  183. // To learn more about this pagination parameter, see
  184. // [Pagination](https://developers.google.com/analytics/devguides/reporting/data/v1/basics#pagination).
  185. int32 row_count = 12;
  186. // Metadata for the report.
  187. ResponseMetaData metadata = 6;
  188. // This Analytics Property's quota state including this request.
  189. PropertyQuota property_quota = 7;
  190. }
  191. // The request to generate a pivot report.
  192. message RunPivotReportRequest {
  193. // A property whose events are tracked. Within a batch request, this entity
  194. // should either be unspecified or consistent with the batch-level entity.
  195. Entity entity = 1;
  196. // The dimensions requested. All defined dimensions must be used by one of the
  197. // following: dimension_expression, dimension_filter, pivots, order_bys.
  198. repeated Dimension dimensions = 2;
  199. // The metrics requested, at least one metric needs to be specified. All
  200. // defined metrics must be used by one of the following: metric_expression,
  201. // metric_filter, order_bys.
  202. repeated Metric metrics = 3;
  203. // The filter clause of dimensions. Dimensions must be requested to be used in
  204. // this filter. Metrics cannot be used in this filter.
  205. FilterExpression dimension_filter = 4;
  206. // The filter clause of metrics. Applied at post aggregation phase, similar to
  207. // SQL having-clause. Metrics must be requested to be used in this filter.
  208. // Dimensions cannot be used in this filter.
  209. FilterExpression metric_filter = 5;
  210. // Describes the visual format of the report's dimensions in columns or rows.
  211. // The union of the fieldNames (dimension names) in all pivots must be a
  212. // subset of dimension names defined in Dimensions. No two pivots can share a
  213. // dimension. A dimension is only visible if it appears in a pivot.
  214. repeated Pivot pivots = 6;
  215. // The date range to retrieve event data for the report. If multiple date
  216. // ranges are specified, event data from each date range is used in the
  217. // report. A special dimension with field name "dateRange" can be included in
  218. // a Pivot's field names; if included, the report compares between date
  219. // ranges. In a cohort request, this `dateRanges` must be unspecified.
  220. repeated DateRange date_ranges = 7;
  221. // A currency code in ISO4217 format, such as "AED", "USD", "JPY".
  222. // If the field is empty, the report uses the entity's default currency.
  223. string currency_code = 8;
  224. // Cohort group associated with this request. If there is a cohort group
  225. // in the request the 'cohort' dimension must be present.
  226. CohortSpec cohort_spec = 9;
  227. // If false or unspecified, each row with all metrics equal to 0 will not be
  228. // returned. If true, these rows will be returned if they are not separately
  229. // removed by a filter.
  230. bool keep_empty_rows = 10;
  231. // Toggles whether to return the current state of this Analytics Property's
  232. // quota. Quota is returned in [PropertyQuota](#PropertyQuota).
  233. bool return_property_quota = 11;
  234. }
  235. // The response pivot report table corresponding to a pivot request.
  236. message RunPivotReportResponse {
  237. // Summarizes the columns and rows created by a pivot. Each pivot in the
  238. // request produces one header in the response. If we have a request like
  239. // this:
  240. //
  241. // "pivots": [{
  242. // "fieldNames": ["country",
  243. // "city"]
  244. // },
  245. // {
  246. // "fieldNames": "eventName"
  247. // }]
  248. //
  249. // We will have the following `pivotHeaders` in the response:
  250. //
  251. // "pivotHeaders" : [{
  252. // "dimensionHeaders": [{
  253. // "dimensionValues": [
  254. // { "value": "United Kingdom" },
  255. // { "value": "London" }
  256. // ]
  257. // },
  258. // {
  259. // "dimensionValues": [
  260. // { "value": "Japan" },
  261. // { "value": "Osaka" }
  262. // ]
  263. // }]
  264. // },
  265. // {
  266. // "dimensionHeaders": [{
  267. // "dimensionValues": [{ "value": "session_start" }]
  268. // },
  269. // {
  270. // "dimensionValues": [{ "value": "scroll" }]
  271. // }]
  272. // }]
  273. repeated PivotHeader pivot_headers = 1;
  274. // Describes dimension columns. The number of DimensionHeaders and ordering of
  275. // DimensionHeaders matches the dimensions present in rows.
  276. repeated DimensionHeader dimension_headers = 7;
  277. // Describes metric columns. The number of MetricHeaders and ordering of
  278. // MetricHeaders matches the metrics present in rows.
  279. repeated MetricHeader metric_headers = 2;
  280. // Rows of dimension value combinations and metric values in the report.
  281. repeated Row rows = 3;
  282. // Aggregation of metric values. Can be totals, minimums, or maximums. The
  283. // returned aggregations are controlled by the metric_aggregations in the
  284. // pivot. The type of aggregation returned in each row is shown by the
  285. // dimension_values which are set to "RESERVED_<MetricAggregation>".
  286. repeated Row aggregates = 4;
  287. // Metadata for the report.
  288. ResponseMetaData metadata = 5;
  289. // This Analytics Property's quota state including this request.
  290. PropertyQuota property_quota = 6;
  291. }
  292. // The batch request containing multiple report requests.
  293. message BatchRunReportsRequest {
  294. // A property whose events are tracked. This entity must be specified for the
  295. // batch. The entity within RunReportRequest may either be unspecified or
  296. // consistent with this entity.
  297. Entity entity = 1;
  298. // Individual requests. Each request has a separate report response. Each
  299. // batch request is allowed up to 5 requests.
  300. repeated RunReportRequest requests = 2;
  301. }
  302. // The batch response containing multiple reports.
  303. message BatchRunReportsResponse {
  304. // Individual responses. Each response has a separate report request.
  305. repeated RunReportResponse reports = 1;
  306. }
  307. // The batch request containing multiple pivot report requests.
  308. message BatchRunPivotReportsRequest {
  309. // A property whose events are tracked. This entity must be specified for the
  310. // batch. The entity within RunPivotReportRequest may either be unspecified or
  311. // consistent with this entity.
  312. Entity entity = 1;
  313. // Individual requests. Each request has a separate pivot report response.
  314. // Each batch request is allowed up to 5 requests.
  315. repeated RunPivotReportRequest requests = 2;
  316. }
  317. // The batch response containing multiple pivot reports.
  318. message BatchRunPivotReportsResponse {
  319. // Individual responses. Each response has a separate pivot report request.
  320. repeated RunPivotReportResponse pivot_reports = 1;
  321. }
  322. // Request for a property's dimension and metric metadata.
  323. message GetMetadataRequest {
  324. // Required. The resource name of the metadata to retrieve. This name field is
  325. // specified in the URL path and not URL parameters. Property is a numeric
  326. // Google Analytics GA4 Property identifier. To learn more, see [where to find
  327. // your Property
  328. // ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id).
  329. //
  330. // Example: properties/1234/metadata
  331. //
  332. // Set the Property ID to 0 for dimensions and metrics common to all
  333. // properties. In this special mode, this method will not return custom
  334. // dimensions and metrics.
  335. string name = 1 [
  336. (google.api.field_behavior) = REQUIRED,
  337. (google.api.resource_reference) = {
  338. type: "analyticsdata.googleapis.com/Metadata"
  339. }
  340. ];
  341. }
  342. // The request to generate a realtime report.
  343. message RunRealtimeReportRequest {
  344. // A Google Analytics GA4 property identifier whose events are tracked.
  345. // Specified in the URL path and not the body. To learn more, see [where to
  346. // find your Property
  347. // ID](https://developers.google.com/analytics/devguides/reporting/data/v1/property-id).
  348. //
  349. // Example: properties/1234
  350. string property = 1;
  351. // The dimensions requested and displayed.
  352. repeated Dimension dimensions = 2;
  353. // The metrics requested and displayed.
  354. repeated Metric metrics = 3;
  355. // The number of rows to return. If unspecified, 10 rows are returned. If
  356. // -1, all rows are returned.
  357. int64 limit = 4;
  358. // The filter clause of dimensions. Dimensions must be requested to be used in
  359. // this filter. Metrics cannot be used in this filter.
  360. FilterExpression dimension_filter = 5;
  361. // The filter clause of metrics. Applied at post aggregation phase, similar to
  362. // SQL having-clause. Metrics must be requested to be used in this filter.
  363. // Dimensions cannot be used in this filter.
  364. FilterExpression metric_filter = 6;
  365. // Aggregation of metrics. Aggregated metric values will be shown in rows
  366. // where the dimension_values are set to "RESERVED_(MetricAggregation)".
  367. repeated MetricAggregation metric_aggregations = 7;
  368. // Specifies how rows are ordered in the response.
  369. repeated OrderBy order_bys = 8;
  370. // Toggles whether to return the current state of this Analytics Property's
  371. // Realtime quota. Quota is returned in [PropertyQuota](#PropertyQuota).
  372. bool return_property_quota = 9;
  373. }
  374. // The response realtime report table corresponding to a request.
  375. message RunRealtimeReportResponse {
  376. // Describes dimension columns. The number of DimensionHeaders and ordering of
  377. // DimensionHeaders matches the dimensions present in rows.
  378. repeated DimensionHeader dimension_headers = 1;
  379. // Describes metric columns. The number of MetricHeaders and ordering of
  380. // MetricHeaders matches the metrics present in rows.
  381. repeated MetricHeader metric_headers = 2;
  382. // Rows of dimension value combinations and metric values in the report.
  383. repeated Row rows = 3;
  384. // If requested, the totaled values of metrics.
  385. repeated Row totals = 4;
  386. // If requested, the maximum values of metrics.
  387. repeated Row maximums = 5;
  388. // If requested, the minimum values of metrics.
  389. repeated Row minimums = 6;
  390. // The total number of rows in the query result, regardless of the number of
  391. // rows returned in the response. For example if a query returns 175 rows and
  392. // includes limit = 50 in the API request, the response will contain row_count
  393. // = 175 but only 50 rows.
  394. int32 row_count = 7;
  395. // This Analytics Property's Realtime quota state including this request.
  396. PropertyQuota property_quota = 8;
  397. }