Advertisement
emanuel1109

Android - view_item_list

Apr 13th, 2022 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // an array where all currently viewed products (products that were loaded on the user's screen) must be included
  2. val items = arrayOf(
  3. Bundle().apply {
  4.     putString(FirebaseAnalytics.Param.ITEM_ID, "6349144490158") // insert an actual product ID
  5.     putString(FirebaseAnalytics.Param.ITEM_NAME, "Rib Support Tank - Black") // insert an actual product name
  6.     putDouble(FirebaseAnalytics.Param.PRICE, 64.00) // insert an actual product price. As a Double. Don't include currency code
  7.     putString(FirebaseAnalytics.Param.CURRENCY, "USD") // insert currency here with the correct format 'USD' 'GBP' 'EUR' etc. ISO-4217 format
  8.     putDouble(FirebaseAnalytics.Param.DISCOUNT, 26.00) // insert an actual product discount. Number or a string. Don't include currency code. Whole number of discount, not percentage. If product price is usually 100 and on sale it is 80, then discount is 20
  9.     putString(FirebaseAnalytics.Param.ITEM_BRAND, "alo") // insert an actual product brand
  10.     putString(FirebaseAnalytics.Param.AFFILIATION, "Alo_US") // insert store name region here
  11.     putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "Women") // insert an actual product top-level category
  12.     putString(FirebaseAnalytics.Param.ITEM_CATEGORY2, "Tops") // if it is possible to drill down the categories (e.g. Apparel, then T-shirt, then Men), use item_category3, etc. Can use from item_category up to item_category5
  13.     putString(FirebaseAnalytics.Param.ITEM_CATEGORY3, "Tanks")
  14.     putString(FirebaseAnalytics.Param.ITEM_CATEGORY4, "")
  15.     putString(FirebaseAnalytics.Param.ITEM_VARIANT, "Black") // insert an actual product variant - in our case the color
  16.     putString(FirebaseAnalytics.Param.ITEM_LIST_NAME, "womens-fdm4") // insert the name of the list where the product is currently displayed
  17.     putLong(FirebaseAnalytics.Param.INDEX, 1)    // insert product's position in that list
  18.     putLong(FirebaseAnalytics.Param.QUANTITY, 1) // product quantity. In case of view_item_list, it will usually be equal to 1
  19. },
  20. Bundle().apply {
  21.     putString(FirebaseAnalytics.Param.ITEM_ID, "6349051265198") // insert an actual product ID
  22.     putString(FirebaseAnalytics.Param.ITEM_NAME, "High-Waist Goddess Legging - Gravel/Pristine") // insert an actual product name
  23.     putDouble(FirebaseAnalytics.Param.PRICE, 102.00) // insert an actual product price. As a Double. Don't include currency code
  24.     putString(FirebaseAnalytics.Param.CURRENCY, "USD") // insert currency here with the correct format 'USD' 'GBP' 'EUR' etc. ISO-4217 format
  25.     putDouble(FirebaseAnalytics.Param.DISCOUNT, 41.00) // insert an actual product discount. Number or a string. Don't include currency code. Whole number of discount, not percentage. If product price is usually 100 and on sale it is 80, then discount is 20
  26.     putString(FirebaseAnalytics.Param.ITEM_BRAND, "alo") // insert an actual product brand
  27.     putString(FirebaseAnalytics.Param.AFFILIATION, "Alo_US") // insert store name region here
  28.     putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "Women") // insert an actual product top-level category
  29.     putString(FirebaseAnalytics.Param.ITEM_CATEGORY2, "Bottoms") // if it is possible to drill down the categories (e.g. Apparel, then T-shirt, then Men), use item_category3, etc. Can use from item_category up to item_category5
  30.     putString(FirebaseAnalytics.Param.ITEM_CATEGORY3, "Leggings")
  31.     putString(FirebaseAnalytics.Param.ITEM_CATEGORY4, "")
  32.     putString(FirebaseAnalytics.Param.ITEM_VARIANT, "Gravel/Pristine") // insert an actual product variant - in our case the color
  33.     putString(FirebaseAnalytics.Param.ITEM_LIST_NAME, "womens-fdm4") // insert the name of the list where the product is currently displayed
  34.     putLong(FirebaseAnalytics.Param.INDEX, 2) // insert product's position in that list
  35.     putLong(FirebaseAnalytics.Param.QUANTITY, 1) // product quantity. In case of view_item_list, it will usually be equal to 1    
  36. })
  37.  
  38. // name of the event. In this case, it always must be view_item_list, each time new products are loaded to the screen from the list, a new event is firing with the items array being the new item batch that just loaded
  39. firebaseAnalytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM_LIST) {
  40.     param(FirebaseAnalytics.Param.ITEMS, items) // an array where all currently viewed products must be included
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement