audience.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. // Copyright 2022 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.admin.v1alpha;
  16. import "google/api/field_behavior.proto";
  17. import "google/api/resource.proto";
  18. import "google/protobuf/duration.proto";
  19. option go_package = "google.golang.org/genproto/googleapis/analytics/admin/v1alpha;admin";
  20. option java_multiple_files = true;
  21. option java_outer_classname = "AudienceProto";
  22. option java_package = "com.google.analytics.admin.v1alpha";
  23. // Specifies how to evaluate users for joining an Audience.
  24. enum AudienceFilterScope {
  25. // Scope is not specified.
  26. AUDIENCE_FILTER_SCOPE_UNSPECIFIED = 0;
  27. // User joins the Audience if the filter condition is met within one
  28. // event.
  29. AUDIENCE_FILTER_SCOPE_WITHIN_SAME_EVENT = 1;
  30. // User joins the Audience if the filter condition is met within one
  31. // session.
  32. AUDIENCE_FILTER_SCOPE_WITHIN_SAME_SESSION = 2;
  33. // User joins the Audience if the filter condition is met by any event
  34. // across any session.
  35. AUDIENCE_FILTER_SCOPE_ACROSS_ALL_SESSIONS = 3;
  36. }
  37. // A specific filter for a single dimension or metric.
  38. message AudienceDimensionOrMetricFilter {
  39. // A filter for a string-type dimension that matches a particular pattern.
  40. message StringFilter {
  41. // The match type for the string filter.
  42. enum MatchType {
  43. // Unspecified
  44. MATCH_TYPE_UNSPECIFIED = 0;
  45. // Exact match of the string value.
  46. EXACT = 1;
  47. // Begins with the string value.
  48. BEGINS_WITH = 2;
  49. // Ends with the string value.
  50. ENDS_WITH = 3;
  51. // Contains the string value.
  52. CONTAINS = 4;
  53. // Full regular expression matches with the string value.
  54. FULL_REGEXP = 5;
  55. // Partial regular expression matches with the string value.
  56. PARTIAL_REGEXP = 6;
  57. }
  58. // Required. The match type for the string filter.
  59. MatchType match_type = 1 [(google.api.field_behavior) = REQUIRED];
  60. // Required. The string value to be matched against.
  61. string value = 2 [(google.api.field_behavior) = REQUIRED];
  62. // Optional. If true, the match is case-sensitive. If false, the match is
  63. // case-insensitive.
  64. bool case_sensitive = 3 [(google.api.field_behavior) = OPTIONAL];
  65. }
  66. // A filter for a string dimension that matches a particular list of options.
  67. message InListFilter {
  68. // Required. The list of possible string values to match against. Must be non-empty.
  69. repeated string values = 1 [(google.api.field_behavior) = REQUIRED];
  70. // Optional. If true, the match is case-sensitive. If false, the match is
  71. // case-insensitive.
  72. bool case_sensitive = 2 [(google.api.field_behavior) = OPTIONAL];
  73. }
  74. // To represent a number.
  75. message NumericValue {
  76. // One of a numeric value.
  77. oneof one_value {
  78. // Integer value.
  79. int64 int64_value = 1;
  80. // Double value.
  81. double double_value = 2;
  82. }
  83. }
  84. // A filter for numeric or date values on a dimension or metric.
  85. message NumericFilter {
  86. // The operation applied to a numeric filter.
  87. enum Operation {
  88. // Unspecified.
  89. OPERATION_UNSPECIFIED = 0;
  90. // Equal.
  91. EQUAL = 1;
  92. // Less than.
  93. LESS_THAN = 2;
  94. // Less than or equal.
  95. LESS_THAN_OR_EQUAL = 3;
  96. // Greater than.
  97. GREATER_THAN = 4;
  98. // Greater than or equal.
  99. GREATER_THAN_OR_EQUAL = 5;
  100. }
  101. // Required. The operation applied to a numeric filter.
  102. Operation operation = 1 [(google.api.field_behavior) = REQUIRED];
  103. // Required. The numeric or date value to match against.
  104. NumericValue value = 2 [(google.api.field_behavior) = REQUIRED];
  105. }
  106. // A filter for numeric or date values between certain values on a dimension
  107. // or metric.
  108. message BetweenFilter {
  109. // Required. Begins with this number, inclusive.
  110. NumericValue from_value = 1 [(google.api.field_behavior) = REQUIRED];
  111. // Required. Ends with this number, inclusive.
  112. NumericValue to_value = 2 [(google.api.field_behavior) = REQUIRED];
  113. }
  114. // One of the above filters.
  115. oneof one_filter {
  116. // A filter for a string-type dimension that matches a particular pattern.
  117. StringFilter string_filter = 2;
  118. // A filter for a string dimension that matches a particular list of
  119. // options.
  120. InListFilter in_list_filter = 3;
  121. // A filter for numeric or date values on a dimension or metric.
  122. NumericFilter numeric_filter = 4;
  123. // A filter for numeric or date values between certain values on a dimension
  124. // or metric.
  125. BetweenFilter between_filter = 5;
  126. }
  127. // Required. Immutable. The dimension name or metric name to filter.
  128. string field_name = 1 [
  129. (google.api.field_behavior) = REQUIRED,
  130. (google.api.field_behavior) = IMMUTABLE
  131. ];
  132. // Optional. Indicates whether this filter needs dynamic evaluation or not. If set to
  133. // true, users join the Audience if they ever met the condition (static
  134. // evaluation). If unset or set to false, user evaluation for an Audience is
  135. // dynamic; users are added to an Audience when they meet the conditions and
  136. // then removed when they no longer meet them.
  137. //
  138. // This can only be set when Audience scope is ACROSS_ALL_SESSIONS.
  139. bool at_any_point_in_time = 6 [(google.api.field_behavior) = OPTIONAL];
  140. // Optional. If set, specifies the time window for which to evaluate data in number of
  141. // days. If not set, then audience data is evaluated against lifetime data
  142. // (i.e., infinite time window).
  143. //
  144. // For example, if set to 1 day, only the current day's data is evaluated. The
  145. // reference point is the current day when at_any_point_in_time is unset or
  146. // false.
  147. //
  148. // It can only be set when Audience scope is ACROSS_ALL_SESSIONS and cannot be
  149. // greater than 60 days.
  150. int32 in_any_n_day_period = 7 [(google.api.field_behavior) = OPTIONAL];
  151. }
  152. // A filter that matches events of a single event name. If an event parameter
  153. // is specified, only the subset of events that match both the single event name
  154. // and the parameter filter expressions match this event filter.
  155. message AudienceEventFilter {
  156. // Required. Immutable. The name of the event to match against.
  157. string event_name = 1 [
  158. (google.api.field_behavior) = REQUIRED,
  159. (google.api.field_behavior) = IMMUTABLE
  160. ];
  161. // Optional. If specified, this filter matches events that match both the single
  162. // event name and the parameter filter expressions. AudienceEventFilter
  163. // inside the parameter filter expression cannot be set (i.e., nested
  164. // event filters are not supported). This should be a single and_group of
  165. // dimension_or_metric_filter or not_expression; ANDs of ORs are not
  166. // supported. Also, if it includes a filter for "eventCount", only that one
  167. // will be considered; all the other filters will be ignored.
  168. AudienceFilterExpression event_parameter_filter_expression = 2 [(google.api.field_behavior) = OPTIONAL];
  169. }
  170. // A logical expression of Audience dimension, metric, or event filters.
  171. message AudienceFilterExpression {
  172. // The expression applied to a filter.
  173. oneof expr {
  174. // A list of expressions to be AND’ed together. It can only contain
  175. // AudienceFilterExpressions with or_group. This must be set for the top
  176. // level AudienceFilterExpression.
  177. AudienceFilterExpressionList and_group = 1;
  178. // A list of expressions to OR’ed together. It cannot contain
  179. // AudienceFilterExpressions with and_group or or_group.
  180. AudienceFilterExpressionList or_group = 2;
  181. // A filter expression to be NOT'ed (i.e., inverted, complemented). It
  182. // can only include a dimension_or_metric_filter. This cannot be set on the
  183. // top level AudienceFilterExpression.
  184. AudienceFilterExpression not_expression = 3;
  185. // A filter on a single dimension or metric. This cannot be set on the top
  186. // level AudienceFilterExpression.
  187. AudienceDimensionOrMetricFilter dimension_or_metric_filter = 4;
  188. // Creates a filter that matches a specific event. This cannot be set on the
  189. // top level AudienceFilterExpression.
  190. AudienceEventFilter event_filter = 5;
  191. }
  192. }
  193. // A list of Audience filter expressions.
  194. message AudienceFilterExpressionList {
  195. // A list of Audience filter expressions.
  196. repeated AudienceFilterExpression filter_expressions = 1;
  197. }
  198. // Defines a simple filter that a user must satisfy to be a member of the
  199. // Audience.
  200. message AudienceSimpleFilter {
  201. // Required. Immutable. Specifies the scope for this filter.
  202. AudienceFilterScope scope = 1 [
  203. (google.api.field_behavior) = REQUIRED,
  204. (google.api.field_behavior) = IMMUTABLE
  205. ];
  206. // Required. Immutable. A logical expression of Audience dimension, metric, or event filters.
  207. AudienceFilterExpression filter_expression = 2 [
  208. (google.api.field_behavior) = REQUIRED,
  209. (google.api.field_behavior) = IMMUTABLE
  210. ];
  211. }
  212. // Defines filters that must occur in a specific order for the user to be a
  213. // member of the Audience.
  214. message AudienceSequenceFilter {
  215. // A condition that must occur in the specified step order for this user
  216. // to match the sequence.
  217. message AudienceSequenceStep {
  218. // Required. Immutable. Specifies the scope for this step.
  219. AudienceFilterScope scope = 1 [
  220. (google.api.field_behavior) = REQUIRED,
  221. (google.api.field_behavior) = IMMUTABLE
  222. ];
  223. // Optional. If true, the event satisfying this step must be the very next event
  224. // after the event satisfying the last step. If unset or false, this
  225. // step indirectly follows the prior step; for example, there may be
  226. // events between the prior step and this step. It is ignored for the
  227. // first step.
  228. bool immediately_follows = 2 [(google.api.field_behavior) = OPTIONAL];
  229. // Optional. When set, this step must be satisfied within the constraint_duration of
  230. // the previous step (i.e., t[i] - t[i-1] <= constraint_duration). If not
  231. // set, there is no duration requirement (the duration is effectively
  232. // unlimited). It is ignored for the first step.
  233. google.protobuf.Duration constraint_duration = 3 [(google.api.field_behavior) = OPTIONAL];
  234. // Required. Immutable. A logical expression of Audience dimension, metric, or event filters in
  235. // each step.
  236. AudienceFilterExpression filter_expression = 4 [
  237. (google.api.field_behavior) = REQUIRED,
  238. (google.api.field_behavior) = IMMUTABLE
  239. ];
  240. }
  241. // Required. Immutable. Specifies the scope for this filter.
  242. AudienceFilterScope scope = 1 [
  243. (google.api.field_behavior) = REQUIRED,
  244. (google.api.field_behavior) = IMMUTABLE
  245. ];
  246. // Optional. Defines the time period in which the whole sequence must occur.
  247. google.protobuf.Duration sequence_maximum_duration = 2 [(google.api.field_behavior) = OPTIONAL];
  248. // Required. An ordered sequence of steps. A user must complete each step in order to
  249. // join the sequence filter.
  250. repeated AudienceSequenceStep sequence_steps = 3 [(google.api.field_behavior) = REQUIRED];
  251. }
  252. // A clause for defining either a simple or sequence filter. A filter can be
  253. // inclusive (i.e., users satisfying the filter clause are included in the
  254. // Audience) or exclusive (i.e., users satisfying the filter clause are
  255. // excluded from the Audience).
  256. message AudienceFilterClause {
  257. // Specifies whether this is an include or exclude filter clause.
  258. enum AudienceClauseType {
  259. // Unspecified clause type.
  260. AUDIENCE_CLAUSE_TYPE_UNSPECIFIED = 0;
  261. // Users will be included in the Audience if the filter clause is met.
  262. INCLUDE = 1;
  263. // Users will be excluded from the Audience if the filter clause is met.
  264. EXCLUDE = 2;
  265. }
  266. oneof filter {
  267. // A simple filter that a user must satisfy to be a member of the Audience.
  268. AudienceSimpleFilter simple_filter = 2;
  269. // Filters that must occur in a specific order for the user to be a member
  270. // of the Audience.
  271. AudienceSequenceFilter sequence_filter = 3;
  272. }
  273. // Required. Specifies whether this is an include or exclude filter clause.
  274. AudienceClauseType clause_type = 1 [(google.api.field_behavior) = REQUIRED];
  275. }
  276. // Specifies an event to log when a user joins the Audience.
  277. message AudienceEventTrigger {
  278. // Determines when to log the event.
  279. enum LogCondition {
  280. // Log condition is not specified.
  281. LOG_CONDITION_UNSPECIFIED = 0;
  282. // The event should be logged only when a user is joined.
  283. AUDIENCE_JOINED = 1;
  284. // The event should be logged whenever the Audience condition is met, even
  285. // if the user is already a member of the Audience.
  286. AUDIENCE_MEMBERSHIP_RENEWED = 2;
  287. }
  288. // Required. The event name that will be logged.
  289. string event_name = 1 [(google.api.field_behavior) = REQUIRED];
  290. // Required. When to log the event.
  291. LogCondition log_condition = 2 [(google.api.field_behavior) = REQUIRED];
  292. }
  293. // A resource message representing a GA4 Audience.
  294. message Audience {
  295. option (google.api.resource) = {
  296. type: "analyticsadmin.googleapis.com/Audience"
  297. pattern: "properties/{property}/audiences/{audience}"
  298. };
  299. // Specifies how long an exclusion lasts for users that meet the exclusion
  300. // filter.
  301. enum AudienceExclusionDurationMode {
  302. // Not specified.
  303. AUDIENCE_EXCLUSION_DURATION_MODE_UNSPECIFIED = 0;
  304. // Exclude users from the Audience during periods when they meet the
  305. // filter clause.
  306. EXCLUDE_TEMPORARILY = 1;
  307. // Exclude users from the Audience if they've ever met the filter clause.
  308. EXCLUDE_PERMANENTLY = 2;
  309. }
  310. // Output only. The resource name for this Audience resource.
  311. // Format: properties/{propertyId}/audiences/{audienceId}
  312. string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
  313. // Required. The display name of the Audience.
  314. string display_name = 2 [(google.api.field_behavior) = REQUIRED];
  315. // Required. The description of the Audience.
  316. string description = 3 [(google.api.field_behavior) = REQUIRED];
  317. // Required. Immutable. The duration a user should stay in an Audience. It cannot be set to more
  318. // than 540 days.
  319. int32 membership_duration_days = 4 [
  320. (google.api.field_behavior) = REQUIRED,
  321. (google.api.field_behavior) = IMMUTABLE
  322. ];
  323. // Output only. It is automatically set by GA to false if this is an NPA Audience and is
  324. // excluded from ads personalization.
  325. bool ads_personalization_enabled = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
  326. // Optional. Specifies an event to log when a user joins the Audience. If not set, no
  327. // event is logged when a user joins the Audience.
  328. AudienceEventTrigger event_trigger = 6 [(google.api.field_behavior) = OPTIONAL];
  329. // Immutable. Specifies how long an exclusion lasts for users that meet the exclusion
  330. // filter. It is applied to all EXCLUDE filter clauses and is ignored when
  331. // there is no EXCLUDE filter clause in the Audience.
  332. AudienceExclusionDurationMode exclusion_duration_mode = 7 [(google.api.field_behavior) = IMMUTABLE];
  333. // Required. Immutable. null Filter clauses that define the Audience. All clauses will be AND’ed
  334. // together.
  335. repeated AudienceFilterClause filter_clauses = 8 [
  336. (google.api.field_behavior) = IMMUTABLE,
  337. (google.api.field_behavior) = REQUIRED,
  338. (google.api.field_behavior) = UNORDERED_LIST
  339. ];
  340. }