user_event.proto 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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.v2alpha;
  16. import "google/api/annotations.proto";
  17. import "google/api/field_behavior.proto";
  18. import "google/cloud/retail/v2alpha/common.proto";
  19. import "google/cloud/retail/v2alpha/product.proto";
  20. import "google/protobuf/timestamp.proto";
  21. import "google/protobuf/wrappers.proto";
  22. option csharp_namespace = "Google.Cloud.Retail.V2Alpha";
  23. option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail";
  24. option java_multiple_files = true;
  25. option java_outer_classname = "UserEventProto";
  26. option java_package = "com.google.cloud.retail.v2alpha";
  27. option objc_class_prefix = "RETAIL";
  28. option php_namespace = "Google\\Cloud\\Retail\\V2alpha";
  29. option ruby_package = "Google::Cloud::Retail::V2alpha";
  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.v2alpha.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.v2alpha.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.v2alpha.PredictResponse.attribution_token]
  86. // for user events that are the result of
  87. // [PredictionService.Predict][google.cloud.retail.v2alpha.PredictionService.Predict].
  88. // The value must be a valid
  89. // [SearchResponse.attribution_token][google.cloud.retail.v2alpha.SearchResponse.attribution_token]
  90. // for user events that are the result of
  91. // [SearchService.Search][google.cloud.retail.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.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.v2alpha.UserEvent.search_query] or
  156. // [page_categories][google.cloud.retail.v2alpha.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
  164. // [SearchRequest.filter][google.cloud.retail.v2alpha.SearchRequest.filter]
  165. // for definition and syntax.
  166. //
  167. // The value must be a UTF-8 encoded string with a length limit of 1,000
  168. // characters. Otherwise, an INVALID_ARGUMENT error is returned.
  169. string filter = 16;
  170. // The order in which products are returned.
  171. //
  172. // See
  173. // [SearchRequest.order_by][google.cloud.retail.v2alpha.SearchRequest.order_by]
  174. // for definition and syntax.
  175. //
  176. // The value must be a UTF-8 encoded string with a length limit of 1,000
  177. // characters. Otherwise, an INVALID_ARGUMENT error is returned.
  178. //
  179. // This can only be set for `search` events. Other event types should not set
  180. // this field. Otherwise, an INVALID_ARGUMENT error is returned.
  181. string order_by = 17;
  182. // An integer that specifies the current offset for pagination (the 0-indexed
  183. // starting location, amongst the products deemed by the API as relevant).
  184. //
  185. // See
  186. // [SearchRequest.offset][google.cloud.retail.v2alpha.SearchRequest.offset]
  187. // for definition.
  188. //
  189. // If this field is negative, an INVALID_ARGUMENT is returned.
  190. //
  191. // This can only be set for `search` events. Other event types should not set
  192. // this field. Otherwise, an INVALID_ARGUMENT error is returned.
  193. int32 offset = 18;
  194. // The categories associated with a category page.
  195. //
  196. // To represent full path of category, use '>' sign to separate different
  197. // hierarchies. If '>' is part of the category name, please replace it with
  198. // other character(s).
  199. //
  200. // Category pages include special pages such as sales or promotions. For
  201. // instance, a special sale page may have the category hierarchy:
  202. // "pageCategories" : ["Sales > 2017 Black Friday Deals"].
  203. //
  204. // Required for `category-page-view` events. At least one of
  205. // [search_query][google.cloud.retail.v2alpha.UserEvent.search_query] or
  206. // [page_categories][google.cloud.retail.v2alpha.UserEvent.page_categories] is
  207. // required for `search` events. Other event types should not set this field.
  208. // Otherwise, an INVALID_ARGUMENT error is returned.
  209. repeated string page_categories = 11;
  210. // User information.
  211. UserInfo user_info = 12;
  212. // Complete URL (window.location.href) of the user's current page.
  213. //
  214. // When using the client side event reporting with JavaScript pixel and Google
  215. // Tag Manager, this value is filled in automatically. Maximum length 5,000
  216. // characters.
  217. string uri = 13;
  218. // The referrer URL of the current page.
  219. //
  220. // When using the client side event reporting with JavaScript pixel and Google
  221. // Tag Manager, this value is filled in automatically.
  222. string referrer_uri = 14;
  223. // A unique id of a web page view.
  224. //
  225. // This should be kept the same for all user events triggered from the same
  226. // pageview. For example, an item detail page view could trigger multiple
  227. // events as the user is browsing the page. The `pageViewId` property should
  228. // be kept the same for all these events so that they can be grouped together
  229. // properly.
  230. //
  231. // When using the client side event reporting with JavaScript pixel and Google
  232. // Tag Manager, this value is filled in automatically.
  233. string page_view_id = 15;
  234. }
  235. // Detailed product information associated with a user event.
  236. message ProductDetail {
  237. // Required. [Product][google.cloud.retail.v2alpha.Product] information.
  238. //
  239. // Only [Product.id][google.cloud.retail.v2alpha.Product.id] field is used
  240. // when ingesting an event, all other product fields are ignored as we will
  241. // look them up from the catalog.
  242. Product product = 1 [(google.api.field_behavior) = REQUIRED];
  243. // Quantity of the product associated with the user event.
  244. //
  245. // For example, this field will be 2 if two products are added to the shopping
  246. // cart for `purchase-complete` event. Required for `add-to-cart` and
  247. // `purchase-complete` event types.
  248. google.protobuf.Int32Value quantity = 2;
  249. }
  250. // Detailed completion information including completion attribution token and
  251. // clicked completion info.
  252. message CompletionDetail {
  253. // Completion attribution token in
  254. // [CompleteQueryResponse.attribution_token][google.cloud.retail.v2alpha.CompleteQueryResponse.attribution_token].
  255. string completion_attribution_token = 1;
  256. // End user selected
  257. // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion].
  258. string selected_suggestion = 2;
  259. // End user selected
  260. // [CompleteQueryResponse.CompletionResult.suggestion][google.cloud.retail.v2alpha.CompleteQueryResponse.CompletionResult.suggestion]
  261. // position, starting from 0.
  262. int32 selected_position = 3;
  263. }
  264. // A transaction represents the entire purchase transaction.
  265. message PurchaseTransaction {
  266. // The transaction ID with a length limit of 128 characters.
  267. string id = 1;
  268. // Required. Total non-zero revenue or grand total associated with the
  269. // transaction. This value include shipping, tax, or other adjustments to
  270. // total revenue that you want to include as part of your revenue
  271. // calculations.
  272. float revenue = 2 [(google.api.field_behavior) = REQUIRED];
  273. // All the taxes associated with the transaction.
  274. float tax = 3;
  275. // All the costs associated with the products. These can be manufacturing
  276. // costs, shipping expenses not borne by the end user, or any other costs,
  277. // such that:
  278. //
  279. // * Profit =
  280. // [revenue][google.cloud.retail.v2alpha.PurchaseTransaction.revenue] -
  281. // [tax][google.cloud.retail.v2alpha.PurchaseTransaction.tax] -
  282. // [cost][google.cloud.retail.v2alpha.PurchaseTransaction.cost]
  283. float cost = 4;
  284. // Required. Currency code. Use three-character ISO-4217 code.
  285. string currency_code = 5 [(google.api.field_behavior) = REQUIRED];
  286. }