Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // an array with a product (or multiple products) that was added to a cart
- val items = arrayOf(
- Bundle().apply {
- putString(FirebaseAnalytics.Param.ITEM_ID, "6349144490158") // insert an actual product ID
- putString(FirebaseAnalytics.Param.ITEM_NAME, "Rib Support Tank - Black") // insert an actual product name
- putDouble(FirebaseAnalytics.Param.PRICE, 64.00) // insert an actual product price. As a Double. Don't include currency code
- putString(FirebaseAnalytics.Param.CURRENCY, "USD") // insert currency here with the correct format 'USD' 'GBP' 'EUR' etc. ISO-4217 format
- 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
- putString(FirebaseAnalytics.Param.ITEM_BRAND, "alo") // insert an actual product brand
- putString(FirebaseAnalytics.Param.AFFILIATION, "Alo_US") // insert store name region here
- putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "Women") // insert an actual product top-level category
- 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
- putString(FirebaseAnalytics.Param.ITEM_CATEGORY3, "Tanks")
- putString(FirebaseAnalytics.Param.ITEM_CATEGORY4, "")
- putString(FirebaseAnalytics.Param.ITEM_VARIANT, "Black / XS") // insert an actual product variant - in our case the color and the size, because when a user adds a product to the cart we already know the size chosen, Black / XS
- putString(FirebaseAnalytics.Param.ITEM_LIST_NAME, "womens-fdm4") // if a product is added to cart directly from product list, add the list name here. If not remove that line
- putLong(FirebaseAnalytics.Param.INDEX, 1) // if a product is added to cart directly from product list, add the position in the list here, if not remove that line
- putLong(FirebaseAnalytics.Param.QUANTITY, 1) // product quantity of how many products were added to a cart
- })
- // Once a user adds a product to the cart, log an ADD_TO_CART event with the chosen product in an items array parameter.
- firebaseAnalytics.logEvent(FirebaseAnalytics.Event.ADD_TO_CART) {
- param(FirebaseAnalytics.Param.ITEMS, items) // an array that contains the product that is being added to the cart
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement