user_event.proto 14 KB

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