Android - Reporting User Activity
Report User Activity
You can report intermediate steps in the checkout funnel for analytics and measurement purposes, including:
- Product Views
- Add To Cart
- Cart Views
This is achieved by first creating a Product, and then reporting it to the Merchant Library.
// Create product item
val product = ButtonProduct()
product.id = "abc123"
product.upc = "012345678901"
product.categories = listOf("Electronics", "Televisions")
product.name = "Flatscreen TV"
product.currency = "USD"
product.value = 39999
product.quantity = 1
product.url = "https://yourbrand.com/p/tv123"
product.attributes = mapOf("size" to "40 inch")
// Report a product view
ButtonMerchant.activity().productViewed(product)
// Report a product added to the cart
ButtonMerchant.activity().productAddedToCart(product)
// Report a cart view
ButtonMerchant.activity().cartViewed(productList)
// Create product item
ButtonProduct product = new ButtonProduct();
List<String> categories = new ArrayList<>();
categories.add("Electronics");
categories.add("Televisions");
Map<String, String> attributes = new HashMap<>();
attributes.put("size", "40 inch");
product.setId("abc123");
product.setUpc("012345678901");
product.setCategories(categories);
product.setName("Flatscreen TV");
product.setCurrency("USD");
product.setValue(39999);
product.setQuantity(1);
product.setUrl("https://yourbrand.com/p/tv123");
product.setAttributes(attributes);
// Report a product view
ButtonMerchant.activity().productViewed(product);
// Report a product added to the cart
ButtonMerchant.activity().productAddedToCart(product);
// Report a cart view
ButtonMerchant.activity().cartViewed(productList);
Note: You can pass your own product object by implementing the ButtonProductCompatible interface on your product class.
Updated 11 months ago