xref: /aosp_15_r20/external/googleapis/google/cloud/retail/v2alpha/user_event.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
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.v2alpha;
18
19import "google/api/field_behavior.proto";
20import "google/cloud/retail/v2alpha/common.proto";
21import "google/cloud/retail/v2alpha/product.proto";
22import "google/protobuf/timestamp.proto";
23import "google/protobuf/wrappers.proto";
24
25option csharp_namespace = "Google.Cloud.Retail.V2Alpha";
26option go_package = "cloud.google.com/go/retail/apiv2alpha/retailpb;retailpb";
27option java_multiple_files = true;
28option java_outer_classname = "UserEventProto";
29option java_package = "com.google.cloud.retail.v2alpha";
30option objc_class_prefix = "RETAIL";
31option php_namespace = "Google\\Cloud\\Retail\\V2alpha";
32option ruby_package = "Google::Cloud::Retail::V2alpha";
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.v2alpha.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.v2alpha.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.v2alpha.PredictResponse.attribution_token]
98  // for user events that are the result of
99  // [PredictionService.Predict][google.cloud.retail.v2alpha.PredictionService.Predict].
100  // The value must be a valid
101  // [SearchResponse.attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token]
102  // for user events that are the result of
103  // [SearchService.Search][google.cloud.retail.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.UserEvent.search_query] or
187  // [page_categories][google.cloud.retail.v2alpha.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
196  // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter]
197  // for definition and syntax.
198  //
199  // The value must be a UTF-8 encoded string with a length limit of 1,000
200  // characters. Otherwise, an INVALID_ARGUMENT error is returned.
201  string filter = 16;
202
203  // The order in which products are returned.
204  //
205  // See
206  // [SearchRequest.order_by][google.cloud.retail.v2alpha.SearchRequest.order_by]
207  // for definition and syntax.
208  //
209  // The value must be a UTF-8 encoded string with a length limit of 1,000
210  // characters. Otherwise, an INVALID_ARGUMENT error is returned.
211  //
212  // This can only be set for `search` events. Other event types should not set
213  // this field. Otherwise, an INVALID_ARGUMENT error is returned.
214  string order_by = 17;
215
216  // An integer that specifies the current offset for pagination (the 0-indexed
217  // starting location, amongst the products deemed by the API as relevant).
218  //
219  // See
220  // [SearchRequest.offset][google.cloud.retail.v2alpha.SearchRequest.offset]
221  // for definition.
222  //
223  // If this field is negative, an INVALID_ARGUMENT is returned.
224  //
225  // This can only be set for `search` events. Other event types should not set
226  // this field. Otherwise, an INVALID_ARGUMENT error is returned.
227  int32 offset = 18;
228
229  // The categories associated with a category page.
230  //
231  // To represent full path of category, use '>' sign to separate different
232  // hierarchies. If '>' is part of the category name, replace it with
233  // other character(s).
234  //
235  // Category pages include special pages such as sales or promotions. For
236  // instance, a special sale page may have the category hierarchy:
237  // "pageCategories" : ["Sales > 2017 Black Friday Deals"].
238  //
239  // Required for `category-page-view` events. At least one of
240  // [search_query][google.cloud.retail.v2alpha.UserEvent.search_query] or
241  // [page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories] is
242  // required for `search` events. Other event types should not set this field.
243  // Otherwise, an INVALID_ARGUMENT error is returned.
244  repeated string page_categories = 11;
245
246  // User information.
247  UserInfo user_info = 12;
248
249  // Complete URL (window.location.href) of the user's current page.
250  //
251  // When using the client side event reporting with JavaScript pixel and Google
252  // Tag Manager, this value is filled in automatically. Maximum length 5,000
253  // characters.
254  string uri = 13;
255
256  // The referrer URL of the current page.
257  //
258  // When using the client side event reporting with JavaScript pixel and Google
259  // Tag Manager, this value is filled in automatically.
260  string referrer_uri = 14;
261
262  // A unique ID of a web page view.
263  //
264  // This should be kept the same for all user events triggered from the same
265  // pageview. For example, an item detail page view could trigger multiple
266  // events as the user is browsing the page. The `pageViewId` property should
267  // be kept the same for all these events so that they can be grouped together
268  // properly.
269  //
270  // When using the client side event reporting with JavaScript pixel and Google
271  // Tag Manager, this value is filled in automatically.
272  string page_view_id = 15;
273
274  // The entity for customers that may run multiple different entities, domains,
275  // sites or regions, for example, `Google US`, `Google Ads`, `Waymo`,
276  // `google.com`, `youtube.com`, etc.
277  // It is recommended to set this field to get better per-entity search,
278  // completion and prediction results.
279  string entity = 23;
280}
281
282// Detailed product information associated with a user event.
283message ProductDetail {
284  // Required. [Product][google.cloud.retail.v2alpha.Product] information.
285  //
286  // Required field(s):
287  //
288  // * [Product.id][google.cloud.retail.v2alpha.Product.id]
289  //
290  // Optional override field(s):
291  //
292  // * [Product.price_info][google.cloud.retail.v2alpha.Product.price_info]
293  //
294  // If any supported optional fields are provided, we will treat them as a full
295  // override when looking up product information from the catalog. Thus, it is
296  // important to ensure that the overriding fields are accurate and
297  // complete.
298  //
299  // All other product fields are ignored and instead populated via catalog
300  // lookup after event ingestion.
301  Product product = 1 [(google.api.field_behavior) = REQUIRED];
302
303  // Quantity of the product associated with the user event.
304  //
305  // For example, this field will be 2 if two products are added to the shopping
306  // cart for `purchase-complete` event. Required for `add-to-cart` and
307  // `purchase-complete` event types.
308  google.protobuf.Int32Value quantity = 2;
309}
310
311// Detailed completion information including completion attribution token and
312// clicked completion info.
313message CompletionDetail {
314  // Completion attribution token in
315  // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2alpha.CompleteQueryResponse.attribution_token].
316  string completion_attribution_token = 1;
317
318  // End user selected
319  // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion].
320  string selected_suggestion = 2;
321
322  // End user selected
323  // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion]
324  // position, starting from 0.
325  int32 selected_position = 3;
326}
327
328// A transaction represents the entire purchase transaction.
329message PurchaseTransaction {
330  // The transaction ID with a length limit of 128 characters.
331  string id = 1;
332
333  // Required. Total non-zero revenue or grand total associated with the
334  // transaction. This value include shipping, tax, or other adjustments to
335  // total revenue that you want to include as part of your revenue
336  // calculations.
337  float revenue = 2 [(google.api.field_behavior) = REQUIRED];
338
339  // All the taxes associated with the transaction.
340  float tax = 3;
341
342  // All the costs associated with the products. These can be manufacturing
343  // costs, shipping expenses not borne by the end user, or any other costs,
344  // such that:
345  //
346  // * Profit =
347  // [revenue][google.cloud.retail.v2alpha.PurchaseTransaction.revenue] -
348  // [tax][google.cloud.retail.v2alpha.PurchaseTransaction.tax] -
349  // [cost][google.cloud.retail.v2alpha.PurchaseTransaction.cost]
350  float cost = 4;
351
352  // Required. Currency code. Use three-character ISO-4217 code.
353  string currency_code = 5 [(google.api.field_behavior) = REQUIRED];
354}
355