1// Copyright 2021 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.cloud.retail.v2beta; 18 19import "google/api/field_behavior.proto"; 20import "google/cloud/retail/v2beta/common.proto"; 21import "google/cloud/retail/v2beta/product.proto"; 22import "google/protobuf/timestamp.proto"; 23import "google/protobuf/wrappers.proto"; 24 25option csharp_namespace = "Google.Cloud.Retail.V2Beta"; 26option go_package = "cloud.google.com/go/retail/apiv2beta/retailpb;retailpb"; 27option java_multiple_files = true; 28option java_outer_classname = "UserEventProto"; 29option java_package = "com.google.cloud.retail.v2beta"; 30option objc_class_prefix = "RETAIL"; 31option php_namespace = "Google\\Cloud\\Retail\\V2beta"; 32option ruby_package = "Google::Cloud::Retail::V2beta"; 33 34// UserEvent captures all metadata information Retail API needs to know about 35// how end users interact with customers' website. 36message UserEvent { 37 // Required. User event type. Allowed values are: 38 // 39 // * `add-to-cart`: Products being added to cart. 40 // * `category-page-view`: Special pages such as sale or promotion pages 41 // viewed. 42 // * `detail-page-view`: Products detail page viewed. 43 // * `home-page-view`: Homepage viewed. 44 // * `promotion-offered`: Promotion is offered to a user. 45 // * `promotion-not-offered`: Promotion is not offered to a user. 46 // * `purchase-complete`: User finishing a purchase. 47 // * `search`: Product search. 48 // * `shopping-cart-page-view`: User viewing a shopping cart. 49 string event_type = 1 [(google.api.field_behavior) = REQUIRED]; 50 51 // Required. A unique identifier for tracking visitors. 52 // 53 // For example, this could be implemented with an HTTP cookie, which should be 54 // able to uniquely identify a visitor on a single device. This unique 55 // identifier should not change if the visitor log in/out of the website. 56 // 57 // Don't set the field to the same fixed ID for different users. This mixes 58 // the event history of those users together, which results in degraded model 59 // quality. 60 // 61 // The field must be a UTF-8 encoded string with a length limit of 128 62 // characters. Otherwise, an INVALID_ARGUMENT error is returned. 63 // 64 // The field should not contain PII or user-data. We recommend to use Google 65 // Analytics [Client 66 // ID](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#clientId) 67 // for this field. 68 string visitor_id = 2 [(google.api.field_behavior) = REQUIRED]; 69 70 // A unique identifier for tracking a visitor session with a length limit of 71 // 128 bytes. A session is an aggregation of an end user behavior in a time 72 // span. 73 // 74 // A general guideline to populate the sesion_id: 75 // 1. If user has no activity for 30 min, a new session_id should be assigned. 76 // 2. The session_id should be unique across users, suggest use uuid or add 77 // visitor_id as prefix. 78 string session_id = 21; 79 80 // Only required for 81 // [UserEventService.ImportUserEvents][google.cloud.retail.v2beta.UserEventService.ImportUserEvents] 82 // method. Timestamp of when the user event happened. 83 google.protobuf.Timestamp event_time = 3; 84 85 // A list of identifiers for the independent experiment groups this user event 86 // belongs to. This is used to distinguish between user events associated with 87 // different experiment setups (e.g. using Retail API, using different 88 // recommendation models). 89 repeated string experiment_ids = 4; 90 91 // Highly recommended for user events that are the result of 92 // [PredictionService.Predict][google.cloud.retail.v2beta.PredictionService.Predict]. 93 // This field enables accurate attribution of recommendation model 94 // performance. 95 // 96 // The value must be a valid 97 // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] 98 // for user events that are the result of 99 // [PredictionService.Predict][google.cloud.retail.v2beta.PredictionService.Predict]. 100 // The value must be a valid 101 // [SearchResponse.attribution_token][google.cloud.retail.v2beta.SearchResponse.attribution_token] 102 // for user events that are the result of 103 // [SearchService.Search][google.cloud.retail.v2beta.SearchService.Search]. 104 // 105 // This token enables us to accurately attribute page view or purchase back to 106 // the event and the particular predict response containing this 107 // clicked/purchased product. If user clicks on product K in the 108 // recommendation results, pass 109 // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] 110 // as a URL parameter to product K's page. When recording events on product 111 // K's page, log the 112 // [PredictResponse.attribution_token][google.cloud.retail.v2beta.PredictResponse.attribution_token] 113 // to this field. 114 string attribution_token = 5; 115 116 // The main product details related to the event. 117 // 118 // This field is optional except for the following event types: 119 // 120 // * `add-to-cart` 121 // * `detail-page-view` 122 // * `purchase-complete` 123 // 124 // In a `search` event, this field represents the products returned to the end 125 // user on the current page (the end user may have not finished browsing the 126 // whole page yet). When a new page is returned to the end user, after 127 // pagination/filtering/ordering even for the same query, a new `search` event 128 // with different 129 // [product_details][google.cloud.retail.v2beta.UserEvent.product_details] is 130 // desired. The end user may have not finished browsing the whole page yet. 131 repeated ProductDetail product_details = 6; 132 133 // The main auto-completion details related to the event. 134 // 135 // This field should be set for `search` event when autocomplete function is 136 // enabled and the user clicks a suggestion for search. 137 CompletionDetail completion_detail = 22; 138 139 // Extra user event features to include in the recommendation model. 140 // 141 // If you provide custom attributes for ingested user events, also include 142 // them in the user events that you associate with prediction requests. Custom 143 // attribute formatting must be consistent between imported events and events 144 // provided with prediction requests. This lets the Retail API use 145 // those custom attributes when training models and serving predictions, which 146 // helps improve recommendation quality. 147 // 148 // This field needs to pass all below criteria, otherwise an INVALID_ARGUMENT 149 // error is returned: 150 // 151 // * The key must be a UTF-8 encoded string with a length limit of 5,000 152 // characters. 153 // * For text attributes, at most 400 values are allowed. Empty values are not 154 // allowed. Each value must be a UTF-8 encoded string with a length limit of 155 // 256 characters. 156 // * For number attributes, at most 400 values are allowed. 157 // 158 // For product recommendations, an example of extra user information is 159 // traffic_channel, which is how a user arrives at the site. Users can arrive 160 // at the site by coming to the site directly, coming through Google 161 // search, or in other ways. 162 map<string, CustomAttribute> attributes = 7; 163 164 // The ID or name of the associated shopping cart. This ID is used 165 // to associate multiple items added or present in the cart before purchase. 166 // 167 // This can only be set for `add-to-cart`, `purchase-complete`, or 168 // `shopping-cart-page-view` events. 169 string cart_id = 8; 170 171 // A transaction represents the entire purchase transaction. 172 // 173 // Required for `purchase-complete` events. Other event types should not set 174 // this field. Otherwise, an INVALID_ARGUMENT error is returned. 175 PurchaseTransaction purchase_transaction = 9; 176 177 // The user's search query. 178 // 179 // See [SearchRequest.query][google.cloud.retail.v2beta.SearchRequest.query] 180 // for definition. 181 // 182 // The value must be a UTF-8 encoded string with a length limit of 5,000 183 // characters. Otherwise, an INVALID_ARGUMENT error is returned. 184 // 185 // At least one of 186 // [search_query][google.cloud.retail.v2beta.UserEvent.search_query] or 187 // [page_categories][google.cloud.retail.v2beta.UserEvent.page_categories] is 188 // required for `search` events. Other event types should not set this field. 189 // Otherwise, an INVALID_ARGUMENT error is returned. 190 string search_query = 10; 191 192 // The filter syntax consists of an expression language for constructing a 193 // predicate from one or more fields of the products being filtered. 194 // 195 // See [SearchRequest.filter][google.cloud.retail.v2beta.SearchRequest.filter] 196 // for definition and syntax. 197 // 198 // The value must be a UTF-8 encoded string with a length limit of 1,000 199 // characters. Otherwise, an INVALID_ARGUMENT error is returned. 200 string filter = 16; 201 202 // The order in which products are returned. 203 // 204 // See 205 // [SearchRequest.order_by][google.cloud.retail.v2beta.SearchRequest.order_by] 206 // for definition and syntax. 207 // 208 // The value must be a UTF-8 encoded string with a length limit of 1,000 209 // characters. Otherwise, an INVALID_ARGUMENT error is returned. 210 // 211 // This can only be set for `search` events. Other event types should not set 212 // this field. Otherwise, an INVALID_ARGUMENT error is returned. 213 string order_by = 17; 214 215 // An integer that specifies the current offset for pagination (the 0-indexed 216 // starting location, amongst the products deemed by the API as relevant). 217 // 218 // See [SearchRequest.offset][google.cloud.retail.v2beta.SearchRequest.offset] 219 // for definition. 220 // 221 // If this field is negative, an INVALID_ARGUMENT is returned. 222 // 223 // This can only be set for `search` events. Other event types should not set 224 // this field. Otherwise, an INVALID_ARGUMENT error is returned. 225 int32 offset = 18; 226 227 // The categories associated with a category page. 228 // 229 // To represent full path of category, use '>' sign to separate different 230 // hierarchies. If '>' is part of the category name, replace it with 231 // other character(s). 232 // 233 // Category pages include special pages such as sales or promotions. For 234 // instance, a special sale page may have the category hierarchy: 235 // "pageCategories" : ["Sales > 2017 Black Friday Deals"]. 236 // 237 // Required for `category-page-view` events. At least one of 238 // [search_query][google.cloud.retail.v2beta.UserEvent.search_query] or 239 // [page_categories][google.cloud.retail.v2beta.UserEvent.page_categories] is 240 // required for `search` events. Other event types should not set this field. 241 // Otherwise, an INVALID_ARGUMENT error is returned. 242 repeated string page_categories = 11; 243 244 // User information. 245 UserInfo user_info = 12; 246 247 // Complete URL (window.location.href) of the user's current page. 248 // 249 // When using the client side event reporting with JavaScript pixel and Google 250 // Tag Manager, this value is filled in automatically. Maximum length 5,000 251 // characters. 252 string uri = 13; 253 254 // The referrer URL of the current page. 255 // 256 // When using the client side event reporting with JavaScript pixel and Google 257 // Tag Manager, this value is filled in automatically. 258 string referrer_uri = 14; 259 260 // A unique ID of a web page view. 261 // 262 // This should be kept the same for all user events triggered from the same 263 // pageview. For example, an item detail page view could trigger multiple 264 // events as the user is browsing the page. The `pageViewId` property should 265 // be kept the same for all these events so that they can be grouped together 266 // properly. 267 // 268 // When using the client side event reporting with JavaScript pixel and Google 269 // Tag Manager, this value is filled in automatically. 270 string page_view_id = 15; 271 272 // The entity for customers that may run multiple different entities, domains, 273 // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`, 274 // `google.com`, `youtube.com`, etc. 275 // It is recommended to set this field to get better per-entity search, 276 // completion and prediction results. 277 string entity = 23; 278} 279 280// Detailed product information associated with a user event. 281message ProductDetail { 282 // Required. [Product][google.cloud.retail.v2beta.Product] information. 283 // 284 // Required field(s): 285 // 286 // * [Product.id][google.cloud.retail.v2beta.Product.id] 287 // 288 // Optional override field(s): 289 // 290 // * [Product.price_info][google.cloud.retail.v2beta.Product.price_info] 291 // 292 // If any supported optional fields are provided, we will treat them as a full 293 // override when looking up product information from the catalog. Thus, it is 294 // important to ensure that the overriding fields are accurate and 295 // complete. 296 // 297 // All other product fields are ignored and instead populated via catalog 298 // lookup after event ingestion. 299 Product product = 1 [(google.api.field_behavior) = REQUIRED]; 300 301 // Quantity of the product associated with the user event. 302 // 303 // For example, this field will be 2 if two products are added to the shopping 304 // cart for `purchase-complete` event. Required for `add-to-cart` and 305 // `purchase-complete` event types. 306 google.protobuf.Int32Value quantity = 2; 307} 308 309// Detailed completion information including completion attribution token and 310// clicked completion info. 311message CompletionDetail { 312 // Completion attribution token in 313 // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2beta.CompleteQueryResponse.attribution_token]. 314 string completion_attribution_token = 1; 315 316 // End user selected 317 // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.suggestion]. 318 string selected_suggestion = 2; 319 320 // End user selected 321 // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2beta.CompleteQueryResponse.CompletionResult.suggestion] 322 // position, starting from 0. 323 int32 selected_position = 3; 324} 325 326// A transaction represents the entire purchase transaction. 327message PurchaseTransaction { 328 // The transaction ID with a length limit of 128 characters. 329 string id = 1; 330 331 // Required. Total non-zero revenue or grand total associated with the 332 // transaction. This value include shipping, tax, or other adjustments to 333 // total revenue that you want to include as part of your revenue 334 // calculations. 335 float revenue = 2 [(google.api.field_behavior) = REQUIRED]; 336 337 // All the taxes associated with the transaction. 338 float tax = 3; 339 340 // All the costs associated with the products. These can be manufacturing 341 // costs, shipping expenses not borne by the end user, or any other costs, 342 // such that: 343 // 344 // * Profit = 345 // [revenue][google.cloud.retail.v2beta.PurchaseTransaction.revenue] - 346 // [tax][google.cloud.retail.v2beta.PurchaseTransaction.tax] - 347 // [cost][google.cloud.retail.v2beta.PurchaseTransaction.cost] 348 float cost = 4; 349 350 // Required. Currency code. Use three-character ISO-4217 code. 351 string currency_code = 5 [(google.api.field_behavior) = REQUIRED]; 352} 353