user_event.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. // Copyright 2020 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.recommendationengine.v1beta1;
  16. import "google/api/field_behavior.proto";
  17. import "google/cloud/recommendationengine/v1beta1/catalog.proto";
  18. import "google/cloud/recommendationengine/v1beta1/common.proto";
  19. import "google/protobuf/timestamp.proto";
  20. option csharp_namespace = "Google.Cloud.RecommendationEngine.V1Beta1";
  21. option go_package = "google.golang.org/genproto/googleapis/cloud/recommendationengine/v1beta1;recommendationengine";
  22. option java_multiple_files = true;
  23. option java_package = "com.google.cloud.recommendationengine.v1beta1";
  24. option objc_class_prefix = "RECAI";
  25. option php_namespace = "Google\\Cloud\\RecommendationEngine\\V1beta1";
  26. option ruby_package = "Google::Cloud::RecommendationEngine::V1beta1";
  27. // UserEvent captures all metadata information recommendation engine needs to
  28. // know about how end users interact with customers' website.
  29. message UserEvent {
  30. // User event source.
  31. enum EventSource {
  32. // Unspecified event source.
  33. EVENT_SOURCE_UNSPECIFIED = 0;
  34. // The event is ingested via a javascript pixel or Recommendations AI Tag
  35. // through automl datalayer or JS Macros.
  36. AUTOML = 1;
  37. // The event is ingested via Recommendations AI Tag through Enhanced
  38. // Ecommerce datalayer.
  39. ECOMMERCE = 2;
  40. // The event is ingested via Import user events API.
  41. BATCH_UPLOAD = 3;
  42. }
  43. // Required. User event type. Allowed values are:
  44. //
  45. // * `add-to-cart` Products being added to cart.
  46. // * `add-to-list` Items being added to a list (shopping list, favorites
  47. // etc).
  48. // * `category-page-view` Special pages such as sale or promotion pages
  49. // viewed.
  50. // * `checkout-start` User starting a checkout process.
  51. // * `detail-page-view` Products detail page viewed.
  52. // * `home-page-view` Homepage viewed.
  53. // * `page-visit` Generic page visits not included in the event types above.
  54. // * `purchase-complete` User finishing a purchase.
  55. // * `refund` Purchased items being refunded or returned.
  56. // * `remove-from-cart` Products being removed from cart.
  57. // * `remove-from-list` Items being removed from a list.
  58. // * `search` Product search.
  59. // * `shopping-cart-page-view` User viewing a shopping cart.
  60. // * `impression` List of items displayed. Used by Google Tag Manager.
  61. string event_type = 1 [(google.api.field_behavior) = REQUIRED];
  62. // Required. User information.
  63. UserInfo user_info = 2 [(google.api.field_behavior) = REQUIRED];
  64. // Optional. User event detailed information common across different
  65. // recommendation types.
  66. EventDetail event_detail = 3 [(google.api.field_behavior) = OPTIONAL];
  67. // Optional. Retail product specific user event metadata.
  68. //
  69. // This field is required for the following event types:
  70. //
  71. // * `add-to-cart`
  72. // * `add-to-list`
  73. // * `category-page-view`
  74. // * `checkout-start`
  75. // * `detail-page-view`
  76. // * `purchase-complete`
  77. // * `refund`
  78. // * `remove-from-cart`
  79. // * `remove-from-list`
  80. // * `search`
  81. //
  82. // This field is optional for the following event types:
  83. //
  84. // * `page-visit`
  85. // * `shopping-cart-page-view` - note that 'product_event_detail' should be
  86. // set for this unless the shopping cart is empty.
  87. //
  88. // This field is not allowed for the following event types:
  89. //
  90. // * `home-page-view`
  91. ProductEventDetail product_event_detail = 4 [(google.api.field_behavior) = OPTIONAL];
  92. // Optional. Only required for ImportUserEvents method. Timestamp of user
  93. // event created.
  94. google.protobuf.Timestamp event_time = 5 [(google.api.field_behavior) = OPTIONAL];
  95. // Optional. This field should *not* be set when using JavaScript pixel
  96. // or the Recommendations AI Tag. Defaults to `EVENT_SOURCE_UNSPECIFIED`.
  97. EventSource event_source = 6 [(google.api.field_behavior) = OPTIONAL];
  98. }
  99. // Information of end users.
  100. message UserInfo {
  101. // Required. A unique identifier for tracking visitors with a length limit of
  102. // 128 bytes.
  103. //
  104. // For example, this could be implemented with a http cookie, which should be
  105. // able to uniquely identify a visitor on a single device. This unique
  106. // identifier should not change if the visitor log in/out of the website.
  107. // Maximum length 128 bytes. Cannot be empty.
  108. string visitor_id = 1 [(google.api.field_behavior) = REQUIRED];
  109. // Optional. Unique identifier for logged-in user with a length limit of 128
  110. // bytes. Required only for logged-in users.
  111. string user_id = 2 [(google.api.field_behavior) = OPTIONAL];
  112. // Optional. IP address of the user. This could be either IPv4 (e.g. 104.133.9.80) or
  113. // IPv6 (e.g. 2001:0db8:85a3:0000:0000:8a2e:0370:7334). This should *not* be
  114. // set when using the javascript pixel or if `direct_user_request` is set.
  115. // Used to extract location information for personalization.
  116. string ip_address = 3 [(google.api.field_behavior) = OPTIONAL];
  117. // Optional. User agent as included in the HTTP header. UTF-8 encoded string
  118. // with a length limit of 1 KiB.
  119. //
  120. // This should *not* be set when using the JavaScript pixel or if
  121. // `directUserRequest` is set.
  122. string user_agent = 4 [(google.api.field_behavior) = OPTIONAL];
  123. // Optional. Indicates if the request is made directly from the end user
  124. // in which case the user_agent and ip_address fields can be populated
  125. // from the HTTP request. This should *not* be set when using the javascript
  126. // pixel. This flag should be set only if the API request is made directly
  127. // from the end user such as a mobile app (and not if a gateway or a server is
  128. // processing and pushing the user events).
  129. bool direct_user_request = 5 [(google.api.field_behavior) = OPTIONAL];
  130. }
  131. // User event details shared by all recommendation types.
  132. message EventDetail {
  133. // Optional. Complete url (window.location.href) of the user's current page.
  134. // When using the JavaScript pixel, this value is filled in automatically.
  135. // Maximum length 5KB.
  136. string uri = 1 [(google.api.field_behavior) = OPTIONAL];
  137. // Optional. The referrer url of the current page. When using
  138. // the JavaScript pixel, this value is filled in automatically.
  139. string referrer_uri = 6 [(google.api.field_behavior) = OPTIONAL];
  140. // Optional. A unique id of a web page view.
  141. // This should be kept the same for all user events triggered from the same
  142. // pageview. For example, an item detail page view could trigger multiple
  143. // events as the user is browsing the page.
  144. // The `pageViewId` property should be kept the same for all these events so
  145. // that they can be grouped together properly. This `pageViewId` will be
  146. // automatically generated if using the JavaScript pixel.
  147. string page_view_id = 2 [(google.api.field_behavior) = OPTIONAL];
  148. // Optional. A list of identifiers for the independent experiment groups
  149. // this user event belongs to. This is used to distinguish between user events
  150. // associated with different experiment setups (e.g. using Recommendation
  151. // Engine system, using different recommendation models).
  152. repeated string experiment_ids = 3 [(google.api.field_behavior) = OPTIONAL];
  153. // Optional. Recommendation token included in the recommendation prediction
  154. // response.
  155. //
  156. // This field enables accurate attribution of recommendation model
  157. // performance.
  158. //
  159. // This token enables us to accurately attribute page view or purchase back to
  160. // the event and the particular predict response containing this
  161. // clicked/purchased item. If user clicks on product K in the recommendation
  162. // results, pass the `PredictResponse.recommendationToken` property as a url
  163. // parameter to product K's page. When recording events on product K's page,
  164. // log the PredictResponse.recommendation_token to this field.
  165. //
  166. // Optional, but highly encouraged for user events that are the result of a
  167. // recommendation prediction query.
  168. string recommendation_token = 4 [(google.api.field_behavior) = OPTIONAL];
  169. // Optional. Extra user event features to include in the recommendation
  170. // model.
  171. //
  172. // For product recommendation, an example of extra user information is
  173. // traffic_channel, i.e. how user arrives at the site. Users can arrive
  174. // at the site by coming to the site directly, or coming through Google
  175. // search, and etc.
  176. FeatureMap event_attributes = 5 [(google.api.field_behavior) = OPTIONAL];
  177. }
  178. // ProductEventDetail captures user event information specific to retail
  179. // products.
  180. message ProductEventDetail {
  181. // Required for `search` events. Other event types should not set this field.
  182. // The user's search query as UTF-8 encoded text with a length limit of 5 KiB.
  183. string search_query = 1;
  184. // Required for `category-page-view` events. Other event types should not set
  185. // this field.
  186. // The categories associated with a category page.
  187. // Category pages include special pages such as sales or promotions. For
  188. // instance, a special sale page may have the category hierarchy:
  189. // categories : ["Sales", "2017 Black Friday Deals"].
  190. repeated CatalogItem.CategoryHierarchy page_categories = 2;
  191. // The main product details related to the event.
  192. //
  193. // This field is required for the following event types:
  194. //
  195. // * `add-to-cart`
  196. // * `add-to-list`
  197. // * `checkout-start`
  198. // * `detail-page-view`
  199. // * `purchase-complete`
  200. // * `refund`
  201. // * `remove-from-cart`
  202. // * `remove-from-list`
  203. //
  204. // This field is optional for the following event types:
  205. //
  206. // * `page-visit`
  207. // * `shopping-cart-page-view` - note that 'product_details' should be set for
  208. // this unless the shopping cart is empty.
  209. //
  210. // This field is not allowed for the following event types:
  211. //
  212. // * `category-page-view`
  213. // * `home-page-view`
  214. // * `search`
  215. repeated ProductDetail product_details = 3;
  216. // Required for `add-to-list` and `remove-from-list` events. The id or name of
  217. // the list that the item is being added to or removed from. Other event types
  218. // should not set this field.
  219. string list_id = 4;
  220. // Optional. The id or name of the associated shopping cart. This id is used
  221. // to associate multiple items added or present in the cart before purchase.
  222. //
  223. // This can only be set for `add-to-cart`, `remove-from-cart`,
  224. // `checkout-start`, `purchase-complete`, or `shopping-cart-page-view` events.
  225. string cart_id = 5 [(google.api.field_behavior) = OPTIONAL];
  226. // Optional. A transaction represents the entire purchase transaction.
  227. // Required for `purchase-complete` events. Optional for `checkout-start`
  228. // events. Other event types should not set this field.
  229. PurchaseTransaction purchase_transaction = 6 [(google.api.field_behavior) = OPTIONAL];
  230. }
  231. // A transaction represents the entire purchase transaction.
  232. message PurchaseTransaction {
  233. // Optional. The transaction ID with a length limit of 128 bytes.
  234. string id = 1 [(google.api.field_behavior) = OPTIONAL];
  235. // Required. Total revenue or grand total associated with the transaction.
  236. // This value include shipping, tax, or other adjustments to total revenue
  237. // that you want to include as part of your revenue calculations. This field
  238. // is not required if the event type is `refund`.
  239. float revenue = 2 [(google.api.field_behavior) = REQUIRED];
  240. // Optional. All the taxes associated with the transaction.
  241. map<string, float> taxes = 3 [(google.api.field_behavior) = OPTIONAL];
  242. // Optional. All the costs associated with the product. These can be
  243. // manufacturing costs, shipping expenses not borne by the end user, or any
  244. // other costs.
  245. //
  246. // Total product cost such that
  247. // profit = revenue - (sum(taxes) + sum(costs))
  248. // If product_cost is not set, then
  249. // profit = revenue - tax - shipping - sum(CatalogItem.costs).
  250. //
  251. // If CatalogItem.cost is not specified for one of the items, CatalogItem.cost
  252. // based profit *cannot* be calculated for this Transaction.
  253. map<string, float> costs = 4 [(google.api.field_behavior) = OPTIONAL];
  254. // Required. Currency code. Use three-character ISO-4217 code. This field
  255. // is not required if the event type is `refund`.
  256. string currency_code = 6 [(google.api.field_behavior) = REQUIRED];
  257. }
  258. // Detailed product information associated with a user event.
  259. message ProductDetail {
  260. // Required. Catalog item ID. UTF-8 encoded string with a length limit of 128
  261. // characters.
  262. string id = 1 [(google.api.field_behavior) = REQUIRED];
  263. // Optional. Currency code for price/costs. Use three-character ISO-4217
  264. // code. Required only if originalPrice or displayPrice is set.
  265. string currency_code = 2 [(google.api.field_behavior) = OPTIONAL];
  266. // Optional. Original price of the product. If provided, this will override
  267. // the original price in Catalog for this product.
  268. float original_price = 3 [(google.api.field_behavior) = OPTIONAL];
  269. // Optional. Display price of the product (e.g. discounted price). If
  270. // provided, this will override the display price in Catalog for this product.
  271. float display_price = 4 [(google.api.field_behavior) = OPTIONAL];
  272. // Optional. Item stock state. If provided, this overrides the stock state
  273. // in Catalog for items in this event.
  274. ProductCatalogItem.StockState stock_state = 5 [(google.api.field_behavior) = OPTIONAL];
  275. // Optional. Quantity of the product associated with the user event. For
  276. // example, this field will be 2 if two products are added to the shopping
  277. // cart for `add-to-cart` event. Required for `add-to-cart`, `add-to-list`,
  278. // `remove-from-cart`, `checkout-start`, `purchase-complete`, `refund` event
  279. // types.
  280. int32 quantity = 6 [(google.api.field_behavior) = OPTIONAL];
  281. // Optional. Quantity of the products in stock when a user event happens.
  282. // Optional. If provided, this overrides the available quantity in Catalog for
  283. // this event. and can only be set if `stock_status` is set to `IN_STOCK`.
  284. //
  285. // Note that if an item is out of stock, you must set the `stock_state` field
  286. // to be `OUT_OF_STOCK`. Leaving this field unspecified / as zero is not
  287. // sufficient to mark the item out of stock.
  288. int32 available_quantity = 7 [(google.api.field_behavior) = OPTIONAL];
  289. // Optional. Extra features associated with a product in the user event.
  290. FeatureMap item_attributes = 8 [(google.api.field_behavior) = OPTIONAL];
  291. }