1// Copyright 2023 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 15syntax = "proto3"; 16 17package google.analytics.data.v1alpha; 18 19import "google/protobuf/duration.proto"; 20 21option go_package = "google.golang.org/genproto/googleapis/analytics/data/v1alpha;data"; 22option java_multiple_files = true; 23option java_outer_classname = "ReportingApiProto"; 24option java_package = "com.google.analytics.data.v1alpha"; 25 26// A contiguous set of days: `startDate`, `startDate + 1`, ..., `endDate`. 27// Requests are allowed up to 4 date ranges. 28message DateRange { 29 // The inclusive start date for the query in the format `YYYY-MM-DD`. Cannot 30 // be after `end_date`. The format `NdaysAgo`, `yesterday`, or `today` is also 31 // accepted, and in that case, the date is inferred based on the property's 32 // reporting time zone. 33 string start_date = 1; 34 35 // The inclusive end date for the query in the format `YYYY-MM-DD`. Cannot 36 // be before `start_date`. The format `NdaysAgo`, `yesterday`, or `today` is 37 // also accepted, and in that case, the date is inferred based on the 38 // property's reporting time zone. 39 string end_date = 2; 40 41 // Assigns a name to this date range. The dimension `dateRange` is valued to 42 // this name in a report response. If set, cannot begin with `date_range_` or 43 // `RESERVED_`. If not set, date ranges are named by their zero based index in 44 // the request: `date_range_0`, `date_range_1`, etc. 45 string name = 3; 46} 47 48// Dimensions are attributes of your data. For example, the dimension city 49// indicates the city from which an event originates. Dimension values in report 50// responses are strings; for example, the city could be "Paris" or "New York". 51message Dimension { 52 // The name of the dimension. See the [API 53 // Dimensions](https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema#dimensions) 54 // for the list of dimension names supported by core reporting methods such 55 // as `runReport` and `batchRunReports`. See 56 // [Realtime 57 // Dimensions](https://developers.google.com/analytics/devguides/reporting/data/v1/realtime-api-schema#dimensions) 58 // for the list of dimension names supported by the `runRealtimeReport` 59 // method. See 60 // [Funnel 61 // Dimensions](https://developers.google.com/analytics/devguides/reporting/data/v1/exploration-api-schema#dimensions) 62 // for the list of dimension names supported by the `runFunnelReport` 63 // method. 64 // 65 // If `dimensionExpression` is specified, `name` can be any string that you 66 // would like within the allowed character set. For example if a 67 // `dimensionExpression` concatenates `country` and `city`, you could call 68 // that dimension `countryAndCity`. Dimension names that you choose must match 69 // the regular expression `^[a-zA-Z0-9_]$`. 70 // 71 // Dimensions are referenced by `name` in `dimensionFilter`, `orderBys`, 72 // `dimensionExpression`, and `pivots`. 73 string name = 1; 74 75 // One dimension can be the result of an expression of multiple dimensions. 76 // For example, dimension "country, city": concatenate(country, ", ", city). 77 DimensionExpression dimension_expression = 2; 78} 79 80// Used to express a dimension which is the result of a formula of multiple 81// dimensions. Example usages: 82// 1) lower_case(dimension) 83// 2) concatenate(dimension1, symbol, dimension2). 84message DimensionExpression { 85 // Used to convert a dimension value to a single case. 86 message CaseExpression { 87 // Name of a dimension. The name must refer back to a name in dimensions 88 // field of the request. 89 string dimension_name = 1; 90 } 91 92 // Used to combine dimension values to a single dimension. 93 message ConcatenateExpression { 94 // Names of dimensions. The names must refer back to names in the dimensions 95 // field of the request. 96 repeated string dimension_names = 1; 97 98 // The delimiter placed between dimension names. 99 // 100 // Delimiters are often single characters such as "|" or "," but can be 101 // longer strings. If a dimension value contains the delimiter, both will be 102 // present in response with no distinction. For example if dimension 1 value 103 // = "US,FR", dimension 2 value = "JP", and delimiter = ",", then the 104 // response will contain "US,FR,JP". 105 string delimiter = 2; 106 } 107 108 // Specify one type of dimension expression for `DimensionExpression`. 109 oneof one_expression { 110 // Used to convert a dimension value to lower case. 111 CaseExpression lower_case = 4; 112 113 // Used to convert a dimension value to upper case. 114 CaseExpression upper_case = 5; 115 116 // Used to combine dimension values to a single dimension. 117 // For example, dimension "country, city": concatenate(country, ", ", city). 118 ConcatenateExpression concatenate = 6; 119 } 120} 121 122// To express dimension or metric filters. The fields in the same 123// FilterExpression need to be either all dimensions or all metrics. 124message FilterExpression { 125 // Specify one type of filter expression for `FilterExpression`. 126 oneof expr { 127 // The FilterExpressions in and_group have an AND relationship. 128 FilterExpressionList and_group = 1; 129 130 // The FilterExpressions in or_group have an OR relationship. 131 FilterExpressionList or_group = 2; 132 133 // The FilterExpression is NOT of not_expression. 134 FilterExpression not_expression = 3; 135 136 // A primitive filter. In the same FilterExpression, all of the filter's 137 // field names need to be either all dimensions or all metrics. 138 Filter filter = 4; 139 } 140} 141 142// A list of filter expressions. 143message FilterExpressionList { 144 // A list of filter expressions. 145 repeated FilterExpression expressions = 1; 146} 147 148// An expression to filter dimension or metric values. 149message Filter { 150 // The dimension name or metric name. Must be a name defined in dimensions 151 // or metrics. 152 string field_name = 1; 153 154 // Specify one type of filter for `Filter`. 155 oneof one_filter { 156 // Strings related filter. 157 StringFilter string_filter = 2; 158 159 // A filter for in list values. 160 InListFilter in_list_filter = 3; 161 162 // A filter for numeric or date values. 163 NumericFilter numeric_filter = 4; 164 165 // A filter for between two values. 166 BetweenFilter between_filter = 5; 167 } 168} 169 170// The filter for string 171message StringFilter { 172 // The match type of a string filter 173 enum MatchType { 174 // Unspecified 175 MATCH_TYPE_UNSPECIFIED = 0; 176 177 // Exact match of the string value. 178 EXACT = 1; 179 180 // Begins with the string value. 181 BEGINS_WITH = 2; 182 183 // Ends with the string value. 184 ENDS_WITH = 3; 185 186 // Contains the string value. 187 CONTAINS = 4; 188 189 // Full match for the regular expression with the string value. 190 FULL_REGEXP = 5; 191 192 // Partial match for the regular expression with the string value. 193 PARTIAL_REGEXP = 6; 194 } 195 196 // The match type for this filter. 197 MatchType match_type = 1; 198 199 // The string value used for the matching. 200 string value = 2; 201 202 // If true, the string value is case sensitive. 203 bool case_sensitive = 3; 204} 205 206// The result needs to be in a list of string values. 207message InListFilter { 208 // The list of string values. 209 // Must be non-empty. 210 repeated string values = 1; 211 212 // If true, the string value is case sensitive. 213 bool case_sensitive = 2; 214} 215 216// Filters for numeric or date values. 217message NumericFilter { 218 // The operation applied to a numeric filter 219 enum Operation { 220 // Unspecified. 221 OPERATION_UNSPECIFIED = 0; 222 223 // Equal 224 EQUAL = 1; 225 226 // Less than 227 LESS_THAN = 2; 228 229 // Less than or equal 230 LESS_THAN_OR_EQUAL = 3; 231 232 // Greater than 233 GREATER_THAN = 4; 234 235 // Greater than or equal 236 GREATER_THAN_OR_EQUAL = 5; 237 } 238 239 // The operation type for this filter. 240 Operation operation = 1; 241 242 // A numeric value or a date value. 243 NumericValue value = 2; 244} 245 246// To express that the result needs to be between two numbers (inclusive). 247message BetweenFilter { 248 // Begins with this number. 249 NumericValue from_value = 1; 250 251 // Ends with this number. 252 NumericValue to_value = 2; 253} 254 255// To represent a number. 256message NumericValue { 257 // One of a numeric value 258 oneof one_value { 259 // Integer value 260 int64 int64_value = 1; 261 262 // Double value 263 double double_value = 2; 264 } 265} 266 267// Describes a dimension column in the report. Dimensions requested in a report 268// produce column entries within rows and DimensionHeaders. However, dimensions 269// used exclusively within filters or expressions do not produce columns in a 270// report; correspondingly, those dimensions do not produce headers. 271message DimensionHeader { 272 // The dimension's name. 273 string name = 1; 274} 275 276// Describes a metric column in the report. Visible metrics requested in a 277// report produce column entries within rows and MetricHeaders. However, 278// metrics used exclusively within filters or expressions do not produce columns 279// in a report; correspondingly, those metrics do not produce headers. 280message MetricHeader { 281 // The metric's name. 282 string name = 1; 283 284 // The metric's data type. 285 MetricType type = 2; 286} 287 288// Report data for each row. 289// For example if RunReportRequest contains: 290// 291// ```none 292// "dimensions": [ 293// { 294// "name": "eventName" 295// }, 296// { 297// "name": "countryId" 298// } 299// ], 300// "metrics": [ 301// { 302// "name": "eventCount" 303// } 304// ] 305// ``` 306// 307// One row with 'in_app_purchase' as the eventName, 'JP' as the countryId, and 308// 15 as the eventCount, would be: 309// 310// ```none 311// "dimensionValues": [ 312// { 313// "value": "in_app_purchase" 314// }, 315// { 316// "value": "JP" 317// } 318// ], 319// "metricValues": [ 320// { 321// "value": "15" 322// } 323// ] 324// ``` 325message Row { 326 // List of requested dimension values. In a PivotReport, dimension_values 327 // are only listed for dimensions included in a pivot. 328 repeated DimensionValue dimension_values = 1; 329 330 // List of requested visible metric values. 331 repeated MetricValue metric_values = 2; 332} 333 334// The value of a dimension. 335message DimensionValue { 336 // One kind of dimension value 337 oneof one_value { 338 // Value as a string if the dimension type is a string. 339 string value = 1; 340 } 341} 342 343// The value of a metric. 344message MetricValue { 345 // One of metric value 346 oneof one_value { 347 // Measurement value. See MetricHeader for type. 348 string value = 4; 349 } 350} 351 352// Current state of all quotas for this Analytics Property. If any quota for a 353// property is exhausted, all requests to that property will return Resource 354// Exhausted errors. 355message PropertyQuota { 356 // Standard Analytics Properties can use up to 200,000 tokens per day; 357 // Analytics 360 Properties can use 2,000,000 tokens per day. Most requests 358 // consume fewer than 10 tokens. 359 QuotaStatus tokens_per_day = 1; 360 361 // Standard Analytics Properties can use up to 40,000 tokens per hour; 362 // Analytics 360 Properties can use 400,000 tokens per hour. An API request 363 // consumes a single number of tokens, and that number is deducted from all of 364 // the hourly, daily, and per project hourly quotas. 365 QuotaStatus tokens_per_hour = 2; 366 367 // Standard Analytics Properties can send up to 10 concurrent requests; 368 // Analytics 360 Properties can use up to 50 concurrent requests. 369 QuotaStatus concurrent_requests = 3; 370 371 // Standard Analytics Properties and cloud project pairs can have up to 10 372 // server errors per hour; Analytics 360 Properties and cloud project pairs 373 // can have up to 50 server errors per hour. 374 QuotaStatus server_errors_per_project_per_hour = 4; 375 376 // Analytics Properties can send up to 120 requests with potentially 377 // thresholded dimensions per hour. In a batch request, each report request 378 // is individually counted for this quota if the request contains potentially 379 // thresholded dimensions. 380 QuotaStatus potentially_thresholded_requests_per_hour = 5; 381 382 // Analytics Properties can use up to 35% of their tokens per project per 383 // hour. This amounts to standard Analytics Properties can use up to 14,000 384 // tokens per project per hour, and Analytics 360 Properties can use 140,000 385 // tokens per project per hour. An API request consumes a single number of 386 // tokens, and that number is deducted from all of the hourly, daily, and per 387 // project hourly quotas. 388 QuotaStatus tokens_per_project_per_hour = 6; 389} 390 391// Current state for a particular quota group. 392message QuotaStatus { 393 // Quota consumed by this request. 394 int32 consumed = 1; 395 396 // Quota remaining after this request. 397 int32 remaining = 2; 398} 399 400// Breakdowns add a dimension to the funnel table sub report response. 401message FunnelBreakdown { 402 // The dimension column added to the funnel table sub report response. The 403 // breakdown dimension breaks down each funnel step. A valid 404 // `breakdownDimension` is required if `funnelBreakdown` is specified. 405 Dimension breakdown_dimension = 1; 406 407 // The maximum number of distinct values of the breakdown dimension to return 408 // in the response. A `limit` of `5` is used if limit is not specified. Limit 409 // must exceed zero and cannot exceed 15. 410 optional int64 limit = 2; 411} 412 413// Next actions state the value for a dimension after the user has achieved 414// a step but before the same user has achieved the next step. For example if 415// the `nextActionDimension` is `eventName`, then `nextActionDimension` in the 416// `i`th funnel step row will return first event after the event that qualified 417// the user into the `i`th funnel step but before the user achieved the `i+1`th 418// funnel step. 419message FunnelNextAction { 420 // The dimension column added to the funnel visualization sub report response. 421 // The next action dimension returns the next dimension value of this 422 // dimension after the user has attained the `i`th funnel step. 423 // 424 // `nextActionDimension` currently only supports `eventName` and most Page / 425 // Screen dimensions like `pageTitle` and `pagePath`. `nextActionDimension` 426 // cannot be a dimension expression. 427 Dimension next_action_dimension = 1; 428 429 // The maximum number of distinct values of the breakdown dimension to return 430 // in the response. A `limit` of `5` is used if limit is not specified. Limit 431 // must exceed zero and cannot exceed 5. 432 optional int64 limit = 2; 433} 434 435// Configures the funnel in a funnel report request. A funnel reports on users 436// as they pass through a sequence of steps. 437// 438// Funnel exploration lets you visualize the steps your users take to complete a 439// task and quickly see how well they are succeeding or failing at each step. 440// For example, how do prospects become shoppers and then become buyers? How do 441// one time buyers become repeat buyers? With this information, you can improve 442// inefficient or abandoned customer journeys. 443message Funnel { 444 // In an open funnel, users can enter the funnel in any step, and in a closed 445 // funnel, users must enter the funnel in the first step. Optional. If 446 // unspecified, a closed funnel is used. 447 bool is_open_funnel = 1; 448 449 // The sequential steps of this funnel. 450 repeated FunnelStep steps = 2; 451} 452 453// Steps define the user journey you want to measure. Steps contain one or 454// more conditions that your users must meet to be included in that step of 455// the funnel journey. 456message FunnelStep { 457 // The distinctive name for this step. If unspecified, steps will be named 458 // by a 1 based indexed name (for example "0. ", "1. ", etc.). This name 459 // defines string value returned by the `funnelStepName` dimension. For 460 // example, specifying `name = Purchase` in the request's third funnel step 461 // will produce `3. Purchase` in the funnel report response. 462 string name = 1; 463 464 // If true, this step must directly follow the previous step. If false, 465 // there can be events between the previous step and this step. If 466 // unspecified, `isDirectlyFollowedBy` is treated as false. 467 bool is_directly_followed_by = 2; 468 469 // If specified, this step must complete within this duration of the 470 // completion of the prior step. `withinDurationFromPriorStep` is inclusive 471 // of the endpoint at the microsecond granularity. For example a duration of 472 // 5 seconds can be completed at 4.9 or 5.0 seconds, but not 5 seconds and 1 473 // microsecond. 474 // 475 // `withinDurationFromPriorStep` is optional, and if unspecified, steps may 476 // be separated by any time duration. 477 optional google.protobuf.Duration within_duration_from_prior_step = 3; 478 479 // The condition that your users must meet to be included in this step of 480 // the funnel journey. 481 FunnelFilterExpression filter_expression = 4; 482} 483 484// Funnel sub reports contain the dimension and metric data values. For example, 485// 12 users reached the second step of the funnel. 486message FunnelSubReport { 487 // Describes dimension columns. Funnel reports always include the funnel step 488 // dimension in sub report responses. Additional dimensions like breakdowns, 489 // dates, and next actions may be present in the response if requested. 490 repeated DimensionHeader dimension_headers = 1; 491 492 // Describes metric columns. Funnel reports always include active users in sub 493 // report responses. The funnel table includes additional metrics like 494 // completion rate, abandonments, and abandonments rate. 495 repeated MetricHeader metric_headers = 2; 496 497 // Rows of dimension value combinations and metric values in the report. 498 repeated Row rows = 3; 499 500 // Metadata for the funnel report. 501 FunnelResponseMetadata metadata = 4; 502} 503 504// User segments are subsets of users who engaged with your site or app. For 505// example, users who have previously purchased; users who added items to their 506// shopping carts, but didn’t complete a purchase. 507message UserSegment { 508 // Defines which users are included in this segment. Optional. 509 UserSegmentCriteria user_inclusion_criteria = 1; 510 511 // Defines which users are excluded in this segment. Optional. 512 UserSegmentExclusion exclusion = 2; 513} 514 515// A user matches a criteria if the user's events meet the conditions in the 516// criteria. 517message UserSegmentCriteria { 518 // A user matches this criteria if the user matches each of these 519 // `andConditionGroups` and each of the `andSequenceGroups`. 520 // `andConditionGroups` may be empty if `andSequenceGroups` are specified. 521 repeated UserSegmentConditionGroup and_condition_groups = 1; 522 523 // A user matches this criteria if the user matches each of these 524 // `andSequenceGroups` and each of the `andConditionGroups`. 525 // `andSequenceGroups` may be empty if `andConditionGroups` are specified. 526 repeated UserSegmentSequenceGroup and_sequence_groups = 2; 527} 528 529// Scoping specifies which events are considered when evaluating if a user 530// meets a criteria. 531enum UserCriteriaScoping { 532 // Unspecified criteria scoping. Do not specify. 533 USER_CRITERIA_SCOPING_UNSPECIFIED = 0; 534 535 // If the criteria is satisfied within one event, the user matches the 536 // criteria. 537 USER_CRITERIA_WITHIN_SAME_EVENT = 1; 538 539 // If the criteria is satisfied within one session, the user matches the 540 // criteria. 541 USER_CRITERIA_WITHIN_SAME_SESSION = 2; 542 543 // If the criteria is satisfied by any events for the user, the user 544 // matches the criteria. 545 USER_CRITERIA_ACROSS_ALL_SESSIONS = 3; 546} 547 548// Conditions tell Analytics what data to include in or exclude from the 549// segment. 550message UserSegmentConditionGroup { 551 // Data is included or excluded from the segment based on if it matches 552 // the condition group. This scoping defines how many events the 553 // `segmentFilterExpression` is evaluated on before the condition group 554 // is determined to be matched or not. For example if `conditionScoping = 555 // USER_CRITERIA_WITHIN_SAME_SESSION`, the expression is evaluated on all 556 // events in a session, and then, the condition group is determined to be 557 // matched or not for this user. For example if `conditionScoping = 558 // USER_CRITERIA_WITHIN_SAME_EVENT`, the expression is evaluated on a single 559 // event, and then, the condition group is determined to be matched or not for 560 // this user. 561 // 562 // Optional. If unspecified, `conditionScoping = ACROSS_ALL_SESSIONS` is 563 // used. 564 UserCriteriaScoping condition_scoping = 1; 565 566 // Data is included or excluded from the segment based on if it matches 567 // this expression. Expressions express criteria on dimension, metrics, 568 // and/or parameters. 569 SegmentFilterExpression segment_filter_expression = 2; 570} 571 572// Define conditions that must occur in a specific order for the user to be 573// a member of the segment. 574message UserSegmentSequenceGroup { 575 // All sequence steps must be satisfied in the scoping for the user to 576 // match the sequence. For example if `sequenceScoping = 577 // USER_CRITERIA_WITHIN_SAME_SESSION`, all sequence steps must complete within 578 // one session for the user to match the sequence. `sequenceScoping = 579 // USER_CRITERIA_WITHIN_SAME_EVENT` is not supported. 580 // 581 // Optional. If unspecified, `conditionScoping = ACROSS_ALL_SESSIONS` is 582 // used. 583 UserCriteriaScoping sequence_scoping = 1; 584 585 // Defines the time period in which the whole sequence must occur; for 586 // example, 30 Minutes. `sequenceMaximumDuration` is inclusive 587 // of the endpoint at the microsecond granularity. For example a sequence 588 // with a maximum duration of 5 seconds can be completed at 4.9 or 5.0 589 // seconds, but not 5 seconds and 1 microsecond. 590 // 591 // `sequenceMaximumDuration` is optional, and if unspecified, sequences can 592 // be completed in any time duration. 593 google.protobuf.Duration sequence_maximum_duration = 2; 594 595 // An ordered sequence of condition steps. A user's events must complete 596 // each step in order for the user to match the 597 // `UserSegmentSequenceGroup`. 598 repeated UserSequenceStep user_sequence_steps = 3; 599} 600 601// A condition that must occur in the specified step order for this user 602// to match the sequence. 603message UserSequenceStep { 604 // If true, the event satisfying this step must be the very next event 605 // after the event satifying the last step. If false, this step indirectly 606 // follows the prior step; for example, there may be events between the 607 // prior step and this step. `isDirectlyFollowedBy` must be false for 608 // the first step. 609 bool is_directly_followed_by = 1; 610 611 // This sequence step must be satisfied in the scoping for the user to 612 // match the sequence. For example if `sequenceScoping = 613 // WITHIN_SAME_SESSION`, this sequence steps must complete within one 614 // session for the user to match the sequence. `stepScoping = 615 // ACROSS_ALL_SESSIONS` is only allowed if the `sequenceScoping = 616 // ACROSS_ALL_SESSIONS`. 617 // 618 // Optional. If unspecified, `stepScoping` uses the same 619 // `UserCriteriaScoping` as the `sequenceScoping`. 620 UserCriteriaScoping step_scoping = 2; 621 622 // A user matches this sequence step if their events match this 623 // expression. Expressions express criteria on dimension, metrics, 624 // and/or parameters. 625 SegmentFilterExpression segment_filter_expression = 3; 626} 627 628// Specifies which users are excluded in this segment. 629message UserSegmentExclusion { 630 // Specifies how long an exclusion will last if a user matches the 631 // `userExclusionCriteria`. 632 // 633 // Optional. If unspecified, `userExclusionDuration` of 634 // `USER_EXCLUSION_TEMPORARY` is used. 635 UserExclusionDuration user_exclusion_duration = 1; 636 637 // If a user meets this condition, the user is excluded from membership in 638 // the segment for the `userExclusionDuration`. 639 UserSegmentCriteria user_exclusion_criteria = 2; 640} 641 642// Enumerates options for how long an exclusion will last if a user matches 643// the `userExclusionCriteria`. 644enum UserExclusionDuration { 645 // Unspecified exclusion duration. Do not specify. 646 USER_EXCLUSION_DURATION_UNSPECIFIED = 0; 647 648 // Temporarily exclude users from the segment during periods when the 649 // user meets the `userExclusionCriteria` condition. 650 USER_EXCLUSION_TEMPORARY = 1; 651 652 // Permanently exclude users from the segment if the user ever meets the 653 // `userExclusionCriteria` condition. 654 USER_EXCLUSION_PERMANENT = 2; 655} 656 657// Session segments are subsets of the sessions that occurred on your site or 658// app: for example, all the sessions that originated from a particular 659// advertising campaign. 660message SessionSegment { 661 // Defines which sessions are included in this segment. Optional. 662 SessionSegmentCriteria session_inclusion_criteria = 1; 663 664 // Defines which sessions are excluded in this segment. Optional. 665 SessionSegmentExclusion exclusion = 2; 666} 667 668// A session matches a criteria if the session's events meet the conditions in 669// the criteria. 670message SessionSegmentCriteria { 671 // A session matches this criteria if the session matches each of these 672 // `andConditionGroups`. 673 repeated SessionSegmentConditionGroup and_condition_groups = 1; 674} 675 676// Scoping specifies which events are considered when evaluating if a 677// session meets a criteria. 678enum SessionCriteriaScoping { 679 // Unspecified criteria scoping. Do not specify. 680 SESSION_CRITERIA_SCOPING_UNSPECIFIED = 0; 681 682 // If the criteria is satisfied within one event, the session matches the 683 // criteria. 684 SESSION_CRITERIA_WITHIN_SAME_EVENT = 1; 685 686 // If the criteria is satisfied within one session, the session matches 687 // the criteria. 688 SESSION_CRITERIA_WITHIN_SAME_SESSION = 2; 689} 690 691// Conditions tell Analytics what data to include in or exclude from the 692// segment. 693message SessionSegmentConditionGroup { 694 // Data is included or excluded from the segment based on if it matches 695 // the condition group. This scoping defines how many events the 696 // `segmentFilterExpression` is evaluated on before the condition group 697 // is determined to be matched or not. For example if `conditionScoping = 698 // SESSION_CRITERIA_WITHIN_SAME_SESSION`, the expression is evaluated on all 699 // events in a session, and then, the condition group is determined to be 700 // matched or not for this session. For example if `conditionScoping = 701 // SESSION_CRITERIA_WITHIN_SAME_EVENT`, the expression is evaluated on a 702 // single event, and then, the condition group is determined to be matched or 703 // not for this session. 704 // 705 // Optional. If unspecified, a `conditionScoping` of `WITHIN_SAME_SESSION` 706 // is used. 707 SessionCriteriaScoping condition_scoping = 1; 708 709 // Data is included or excluded from the segment based on if it matches 710 // this expression. Expressions express criteria on dimension, metrics, 711 // and/or parameters. 712 SegmentFilterExpression segment_filter_expression = 2; 713} 714 715// Specifies which sessions are excluded in this segment. 716message SessionSegmentExclusion { 717 // Specifies how long an exclusion will last if a session matches the 718 // `sessionExclusionCriteria`. 719 // 720 // Optional. If unspecified, a `sessionExclusionDuration` of 721 // `SESSION_EXCLUSION_TEMPORARY` is used. 722 SessionExclusionDuration session_exclusion_duration = 1; 723 724 // If a session meets this condition, the session is excluded from 725 // membership in the segment for the `sessionExclusionDuration`. 726 SessionSegmentCriteria session_exclusion_criteria = 2; 727} 728 729// Enumerates options for how long an exclusion will last if a session 730// matches the `sessionExclusionCriteria`. 731enum SessionExclusionDuration { 732 // Unspecified exclusion duration. Do not specify. 733 SESSION_EXCLUSION_DURATION_UNSPECIFIED = 0; 734 735 // Temporarily exclude sessions from the segment during periods when the 736 // session meets the `sessionExclusionCriteria` condition. 737 SESSION_EXCLUSION_TEMPORARY = 1; 738 739 // Permanently exclude sessions from the segment if the session ever meets 740 // the `sessionExclusionCriteria` condition. 741 SESSION_EXCLUSION_PERMANENT = 2; 742} 743 744// Event segments are subsets of events that were triggered on your site or app. 745// for example, all purchase events made in a particular location; app_exception 746// events that occurred on a specific operating system. 747message EventSegment { 748 // Defines which events are included in this segment. Optional. 749 EventSegmentCriteria event_inclusion_criteria = 1; 750 751 // Defines which events are excluded in this segment. Optional. 752 EventSegmentExclusion exclusion = 2; 753} 754 755// An event matches a criteria if the event meet the conditions in the 756// criteria. 757message EventSegmentCriteria { 758 // An event matches this criteria if the event matches each of these 759 // `andConditionGroups`. 760 repeated EventSegmentConditionGroup and_condition_groups = 1; 761} 762 763// Scoping specifies which events are considered when evaluating if an event 764// meets a criteria. 765enum EventCriteriaScoping { 766 // Unspecified criteria scoping. Do not specify. 767 EVENT_CRITERIA_SCOPING_UNSPECIFIED = 0; 768 769 // If the criteria is satisfied within one event, the event matches the 770 // criteria. 771 EVENT_CRITERIA_WITHIN_SAME_EVENT = 1; 772} 773 774// Conditions tell Analytics what data to include in or exclude from the 775// segment. 776message EventSegmentConditionGroup { 777 // `conditionScoping` should always be `EVENT_CRITERIA_WITHIN_SAME_EVENT`. 778 // 779 // Optional. If unspecified, a `conditionScoping` of 780 // `EVENT_CRITERIA_WITHIN_SAME_EVENT` is used. 781 EventCriteriaScoping condition_scoping = 1; 782 783 // Data is included or excluded from the segment based on if it matches 784 // this expression. Expressions express criteria on dimension, metrics, 785 // and/or parameters. 786 SegmentFilterExpression segment_filter_expression = 2; 787} 788 789// Specifies which events are excluded in this segment. 790message EventSegmentExclusion { 791 // `eventExclusionDuration` should always be `PERMANENTLY_EXCLUDE`. 792 // 793 // Optional. If unspecified, an `eventExclusionDuration` of 794 // `EVENT_EXCLUSION_PERMANENT` is used. 795 EventExclusionDuration event_exclusion_duration = 1; 796 797 // If an event meets this condition, the event is excluded from membership 798 // in the segment for the `eventExclusionDuration`. 799 EventSegmentCriteria event_exclusion_criteria = 2; 800} 801 802// Enumerates options for how long an exclusion will last if an event 803// matches the `eventExclusionCriteria`. 804enum EventExclusionDuration { 805 // Unspecified exclusion duration. Do not specify. 806 EVENT_EXCLUSION_DURATION_UNSPECIFIED = 0; 807 808 // Permanently exclude events from the segment if the event ever meets 809 // the `eventExclusionCriteria` condition. 810 EVENT_EXCLUSION_PERMANENT = 1; 811} 812 813// A segment is a subset of your Analytics data. For example, of your entire set 814// of users, one segment might be users from a particular country or city. 815// Another segment might be users who purchase a particular line of products or 816// who visit a specific part of your site or trigger certain events in your app. 817// 818// To learn more, see [GA4 Segment 819// Builder](https://support.google.com/analytics/answer/9304353). 820message Segment { 821 // The name for this segment. If unspecified, segments are named "Segment". 822 // This name defines string value returned by the `segment` dimension. The 823 // `segment` dimension prefixes segment names by the 1-based index number of 824 // the segment in the request (for example "1. Segment", "2. Segment", etc.). 825 string name = 1; 826 827 // A segment is specified in one scope. 828 oneof one_segment_scope { 829 // User segments are subsets of users who engaged with your site or app. 830 UserSegment user_segment = 2; 831 832 // Session segments are subsets of the sessions that occurred on your site 833 // or app. 834 SessionSegment session_segment = 3; 835 836 // Event segments are subsets of events that were triggered on your site or 837 // app. 838 EventSegment event_segment = 4; 839 } 840} 841 842// Expresses combinations of segment filters. 843message SegmentFilterExpression { 844 // Specify one type of filter for `SegmentFilterExpression`. 845 oneof expr { 846 // The SegmentFilterExpression in `andGroup` have an AND relationship. 847 SegmentFilterExpressionList and_group = 1; 848 849 // The SegmentFilterExpression in `orGroup` have an OR relationship. 850 SegmentFilterExpressionList or_group = 2; 851 852 // The SegmentFilterExpression is NOT of `notExpression`. 853 SegmentFilterExpression not_expression = 3; 854 855 // A primitive segment filter. 856 SegmentFilter segment_filter = 4; 857 858 // Creates a filter that matches events of a single event name. If a 859 // parameter filter expression is specified, only the subset of events that 860 // match both the single event name and the parameter filter expressions 861 // match this event filter. 862 SegmentEventFilter segment_event_filter = 5; 863 } 864} 865 866// A list of segment filter expressions. 867message SegmentFilterExpressionList { 868 // The list of segment filter expressions 869 repeated SegmentFilterExpression expressions = 1; 870} 871 872// An expression to filter dimension or metric values. 873message SegmentFilter { 874 // The dimension name or metric name. 875 string field_name = 1; 876 877 // Specify one type of filter for `Filter`. 878 oneof one_filter { 879 // Strings related filter. 880 StringFilter string_filter = 4; 881 882 // A filter for in list values. 883 InListFilter in_list_filter = 5; 884 885 // A filter for numeric or date values. 886 NumericFilter numeric_filter = 6; 887 888 // A filter for between two values. 889 BetweenFilter between_filter = 7; 890 } 891 892 // Specifies the scope for the filter. 893 SegmentFilterScoping filter_scoping = 8; 894} 895 896// Scopings specify how the dimensions & metrics of multiple events 897// should be considered when evaluating a segment filter. 898message SegmentFilterScoping { 899 // If `atAnyPointInTime` is true, this filter evaluates to true for all 900 // events if it evaluates to true for any event in the date range of the 901 // request. 902 // 903 // This `atAnyPointInTime` parameter does not extend the date range of 904 // events in the report. If `atAnyPointInTime` is true, only events within 905 // the report's date range are considered when evaluating this filter. 906 // 907 // This `atAnyPointInTime` is only able to be specified if the criteria 908 // scoping is `ACROSS_ALL_SESSIONS` and is not able to be specified in 909 // sequences. 910 // 911 // If the criteria scoping is `ACROSS_ALL_SESSIONS`, `atAnyPointInTime` = 912 // false is used if unspecified. 913 optional bool at_any_point_in_time = 1; 914} 915 916// Creates a filter that matches events of a single event name. If a parameter 917// filter expression is specified, only the subset of events that match both the 918// single event name and the parameter filter expressions match this event 919// filter. 920message SegmentEventFilter { 921 // This filter matches events of this single event name. Event name is 922 // required. 923 optional string event_name = 1; 924 925 // If specified, this filter matches events that match both the single event 926 // name and the parameter filter expressions. 927 // 928 // Inside the parameter filter expression, only parameter filters are 929 // available. 930 optional SegmentParameterFilterExpression 931 segment_parameter_filter_expression = 2; 932} 933 934// Expresses combinations of segment filter on parameters. 935message SegmentParameterFilterExpression { 936 // Specify one type of filter for `SegmentParameterFilterExpression`. 937 oneof expr { 938 // The SegmentParameterFilterExpression in `andGroup` have an AND 939 // relationship. 940 SegmentParameterFilterExpressionList and_group = 1; 941 942 // The SegmentParameterFilterExpression in `orGroup` have an OR 943 // relationship. 944 SegmentParameterFilterExpressionList or_group = 2; 945 946 // The SegmentParameterFilterExpression is NOT of `notExpression`. 947 SegmentParameterFilterExpression not_expression = 3; 948 949 // A primitive segment parameter filter. 950 SegmentParameterFilter segment_parameter_filter = 4; 951 } 952} 953 954// A list of segment parameter filter expressions. 955message SegmentParameterFilterExpressionList { 956 // The list of segment parameter filter expressions. 957 repeated SegmentParameterFilterExpression expressions = 1; 958} 959 960// An expression to filter parameter values in a segment. 961message SegmentParameterFilter { 962 // The field that is being filtered. 963 oneof one_parameter { 964 // This filter will be evaluated on the specified event parameter. Event 965 // parameters are logged as parameters of the event. Event parameters 966 // include fields like "firebase_screen" & "currency". 967 // 968 // Event parameters can only be used in segments & funnels and can only be 969 // used in a descendent filter from an EventFilter. In a descendent filter 970 // from an EventFilter either event or item parameters should be used. 971 string event_parameter_name = 1; 972 973 // This filter will be evaluated on the specified item parameter. Item 974 // parameters are logged as parameters in the item array. Item parameters 975 // include fields like "item_name" & "item_category". 976 // 977 // Item parameters can only be used in segments & funnels and can only be 978 // used in a descendent filter from an EventFilter. In a descendent filter 979 // from an EventFilter either event or item parameters should be used. 980 // 981 // Item parameters are only available in ecommerce events. To learn more 982 // about ecommerce events, see the [Measure ecommerce] 983 // (https://developers.google.com/analytics/devguides/collection/ga4/ecommerce) 984 // guide. 985 string item_parameter_name = 2; 986 } 987 988 // Specify one type of filter. 989 oneof one_filter { 990 // Strings related filter. 991 StringFilter string_filter = 4; 992 993 // A filter for in list values. 994 InListFilter in_list_filter = 5; 995 996 // A filter for numeric or date values. 997 NumericFilter numeric_filter = 6; 998 999 // A filter for between two values. 1000 BetweenFilter between_filter = 7; 1001 } 1002 1003 // Specifies the scope for the filter. 1004 SegmentParameterFilterScoping filter_scoping = 8; 1005} 1006 1007// Scopings specify how multiple events should be considered when evaluating a 1008// segment parameter filter. 1009message SegmentParameterFilterScoping { 1010 // Accumulates the parameter over the specified period of days before 1011 // applying the filter. Only supported if criteria scoping is 1012 // `ACROSS_ALL_SESSIONS` or `WITHIN_SAME_SESSION`. Only supported if the 1013 // parameter is `event_count`. 1014 // 1015 // For example if `inAnyNDayPeriod` is 3, the event_name is "purchase", 1016 // the event parameter is "event_count", and the Filter's criteria is 1017 // greater than 5, this filter will accumulate the event count of purchase 1018 // events over every 3 consecutive day period in the report's date range; a 1019 // user will pass this Filter's criteria to be included in this segment if 1020 // their count of purchase events exceeds 5 in any 3 consecutive day period. 1021 // For example, the periods 2021-11-01 to 2021-11-03, 2021-11-02 to 1022 // 2021-11-04, 2021-11-03 to 2021-11-05, and etc. will be considered. 1023 // 1024 // The date range is not extended for the purpose of having a full N day 1025 // window near the start of the date range. For example if a report is for 1026 // 2021-11-01 to 2021-11-10 and `inAnyNDayPeriod` = 3, the first two day 1027 // period will be effectively shortened because no event data outside the 1028 // report's date range will be read. For example, the first four periods 1029 // will effectively be: 2021-11-01 to 2021-11-01, 2021-11-01 to 2021-11-02, 1030 // 2021-11-01 to 2021-11-03, and 2021-11-02 to 2021-11-04. 1031 // 1032 // `inAnyNDayPeriod` is optional. If not specified, the 1033 // `segmentParameterFilter` is applied to each event individually. 1034 optional int64 in_any_n_day_period = 1; 1035} 1036 1037// Expresses combinations of funnel filters. 1038message FunnelFilterExpression { 1039 // Specify one type of filter for `FunnelFilterExpression`. 1040 oneof expr { 1041 // The FunnelFilterExpression in `andGroup` have an AND relationship. 1042 FunnelFilterExpressionList and_group = 1; 1043 1044 // The FunnelFilterExpression in `orGroup` have an OR relationship. 1045 FunnelFilterExpressionList or_group = 2; 1046 1047 // The FunnelFilterExpression is NOT of `notExpression`. 1048 FunnelFilterExpression not_expression = 3; 1049 1050 // A funnel filter for a dimension or metric. 1051 FunnelFieldFilter funnel_field_filter = 4; 1052 1053 // Creates a filter that matches events of a single event name. If a 1054 // parameter filter expression is specified, only the subset of events that 1055 // match both the single event name and the parameter filter expressions 1056 // match this event filter. 1057 FunnelEventFilter funnel_event_filter = 5; 1058 } 1059} 1060 1061// A list of funnel filter expressions. 1062message FunnelFilterExpressionList { 1063 // The list of funnel filter expressions. 1064 repeated FunnelFilterExpression expressions = 1; 1065} 1066 1067// An expression to filter dimension or metric values. 1068message FunnelFieldFilter { 1069 // The dimension name or metric name. 1070 string field_name = 1; 1071 1072 // Specify one type of filter. 1073 oneof one_filter { 1074 // Strings related filter. 1075 StringFilter string_filter = 4; 1076 1077 // A filter for in list values. 1078 InListFilter in_list_filter = 5; 1079 1080 // A filter for numeric or date values. 1081 NumericFilter numeric_filter = 6; 1082 1083 // A filter for between two values. 1084 BetweenFilter between_filter = 7; 1085 } 1086} 1087 1088// Creates a filter that matches events of a single event name. If a parameter 1089// filter expression is specified, only the subset of events that match both the 1090// single event name and the parameter filter expressions match this event 1091// filter. 1092message FunnelEventFilter { 1093 // This filter matches events of this single event name. Event name is 1094 // required. 1095 optional string event_name = 1; 1096 1097 // If specified, this filter matches events that match both the single event 1098 // name and the parameter filter expressions. 1099 // 1100 // Inside the parameter filter expression, only parameter filters are 1101 // available. 1102 optional FunnelParameterFilterExpression funnel_parameter_filter_expression = 1103 2; 1104} 1105 1106// Expresses combinations of funnel filters on parameters. 1107message FunnelParameterFilterExpression { 1108 // Specify one type of filter for `FunnelParameterFilterExpression`. 1109 oneof expr { 1110 // The FunnelParameterFilterExpression in `andGroup` have an AND 1111 // relationship. 1112 FunnelParameterFilterExpressionList and_group = 1; 1113 1114 // The FunnelParameterFilterExpression in `orGroup` have an OR 1115 // relationship. 1116 FunnelParameterFilterExpressionList or_group = 2; 1117 1118 // The FunnelParameterFilterExpression is NOT of `notExpression`. 1119 FunnelParameterFilterExpression not_expression = 3; 1120 1121 // A primitive funnel parameter filter. 1122 FunnelParameterFilter funnel_parameter_filter = 4; 1123 } 1124} 1125 1126// A list of funnel parameter filter expressions. 1127message FunnelParameterFilterExpressionList { 1128 // The list of funnel parameter filter expressions. 1129 repeated FunnelParameterFilterExpression expressions = 1; 1130} 1131 1132// An expression to filter parameter values in a funnel. 1133message FunnelParameterFilter { 1134 // The field that is being filtered. 1135 oneof one_parameter { 1136 // This filter will be evaluated on the specified event parameter. Event 1137 // parameters are logged as parameters of the event. Event parameters 1138 // include fields like "firebase_screen" & "currency". 1139 // 1140 // Event parameters can only be used in segments & funnels and can only be 1141 // used in a descendent filter from an EventFilter. In a descendent filter 1142 // from an EventFilter either event or item parameters should be used. 1143 string event_parameter_name = 1; 1144 1145 // This filter will be evaluated on the specified item parameter. Item 1146 // parameters are logged as parameters in the item array. Item parameters 1147 // include fields like "item_name" & "item_category". 1148 // 1149 // Item parameters can only be used in segments & funnels and can only be 1150 // used in a descendent filter from an EventFilter. In a descendent filter 1151 // from an EventFilter either event or item parameters should be used. 1152 // 1153 // Item parameters are only available in ecommerce events. To learn more 1154 // about ecommerce events, see the [Measure ecommerce] 1155 // (https://developers.google.com/analytics/devguides/collection/ga4/ecommerce) 1156 // guide. 1157 string item_parameter_name = 2; 1158 } 1159 1160 // Specify one type of filter. 1161 oneof one_filter { 1162 // Strings related filter. 1163 StringFilter string_filter = 4; 1164 1165 // A filter for in list values. 1166 InListFilter in_list_filter = 5; 1167 1168 // A filter for numeric or date values. 1169 NumericFilter numeric_filter = 6; 1170 1171 // A filter for between two values. 1172 BetweenFilter between_filter = 7; 1173 } 1174} 1175 1176// The funnel report's response metadata carries additional information about 1177// the funnel report. 1178message FunnelResponseMetadata { 1179 // If funnel report results are 1180 // [sampled](https://support.google.com/analytics/answer/13331292), this 1181 // describes what percentage of events were used in this funnel report. One 1182 // `samplingMetadatas` is populated for each date range. Each 1183 // `samplingMetadatas` corresponds to a date range in order that date ranges 1184 // were specified in the request. 1185 // 1186 // However if the results are not sampled, this field will not be defined. 1187 repeated SamplingMetadata sampling_metadatas = 1; 1188} 1189 1190// If funnel report results are 1191// [sampled](https://support.google.com/analytics/answer/13331292), this 1192// metadata describes what percentage of events were used in this funnel 1193// report for a date range. Sampling is the practice of analyzing a subset of 1194// all data in order to uncover the meaningful information in the larger data 1195// set. 1196message SamplingMetadata { 1197 // The total number of events read in this sampled report for a date range. 1198 // This is the size of the subset this property's data that was analyzed in 1199 // this funnel report. 1200 int64 samples_read_count = 1; 1201 1202 // The total number of events present in this property's data that could 1203 // have been analyzed in this funnel report for a date range. Sampling 1204 // uncovers the meaningful information about the larger data set, and this 1205 // is the size of the larger data set. 1206 // 1207 // To calculate the percentage of available data that was used in this 1208 // funnel report, compute `samplesReadCount/samplingSpaceSize`. 1209 int64 sampling_space_size = 2; 1210} 1211 1212// A metric's value type. 1213enum MetricType { 1214 // Unspecified type. 1215 METRIC_TYPE_UNSPECIFIED = 0; 1216 1217 // Integer type. 1218 TYPE_INTEGER = 1; 1219 1220 // Floating point type. 1221 TYPE_FLOAT = 2; 1222 1223 // A duration of seconds; a special floating point type. 1224 TYPE_SECONDS = 4; 1225 1226 // A duration in milliseconds; a special floating point type. 1227 TYPE_MILLISECONDS = 5; 1228 1229 // A duration in minutes; a special floating point type. 1230 TYPE_MINUTES = 6; 1231 1232 // A duration in hours; a special floating point type. 1233 TYPE_HOURS = 7; 1234 1235 // A custom metric of standard type; a special floating point type. 1236 TYPE_STANDARD = 8; 1237 1238 // An amount of money; a special floating point type. 1239 TYPE_CURRENCY = 9; 1240 1241 // A length in feet; a special floating point type. 1242 TYPE_FEET = 10; 1243 1244 // A length in miles; a special floating point type. 1245 TYPE_MILES = 11; 1246 1247 // A length in meters; a special floating point type. 1248 TYPE_METERS = 12; 1249 1250 // A length in kilometers; a special floating point type. 1251 TYPE_KILOMETERS = 13; 1252} 1253