Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Products can be instrumented as an array of items that can be added to prescribed ecommerce events.
- //To measure how many times product details are viewed, log a view_item event whenever a user views a product’s details screen.
- // A pair of jeggings (product1)
- Bundle itemJeggings = new Bundle();
- itemJeggings.putString(FirebaseAnalytics.Param.ITEM_ID, "SKU_123"); //Item ID (context-specific) (String).
- itemJeggings.putString(FirebaseAnalytics.Param.ITEM_NAME, "jeggings"); //Item Name (context-specific) (String).
- itemJeggings.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "pants"); //Item category (context-specific) (String).
- itemJeggings.putString(FirebaseAnalytics.Param.ITEM_CATEGORY2, "sub-cat1"); //Item sub-category (context-specific) (String).
- itemJeggings.putString(FirebaseAnalytics.Param.ITEM_CATEGORY3, "sub-cat2"); //Item sub-category (context-specific) (String).
- itemJeggings.putString(FirebaseAnalytics.Param.ITEM_CATEGORY4, "sub-cat3"); //Item sub-category (context-specific) (String).
- itemJeggings.putString(FirebaseAnalytics.Param.ITEM_CATEGORY5, "sub-cat4"); //Item sub-category (context-specific) (String).
- itemJeggings.putString(FirebaseAnalytics.Param.ITEM_VARIANT, "black"); //Item variant (String).
- itemJeggings.putString(FirebaseAnalytics.Param.ITEM_BRAND, "Google"); //Item brand. The parameter expects a string value
- itemJeggings.putDouble(FirebaseAnalytics.Param.PRICE, 9.99); //Product price (double). Expecting a double value
- Bundle viewItemParams = new Bundle();
- viewItemParams.putString(FirebaseAnalytics.Param.CURRENCY, "USD"); //Currency of the purchase or items associated with the event, in 3-letter ISO_4217 format (String). The parameter expects a string value set with BaseBundle.putString(String, String)
- viewItemParams.putDouble(FirebaseAnalytics.Param.VALUE, 9.99);
- new Parcelable[] { itemJeggings }); //A context-specific numeric value which is accumulated automatically for each event type. Value should be specified with BaseBundle.putLong(String, long) or BaseBundle.putDouble(String, double). Note: Values for pre-defined currency-related events should be accompanied by a CURRENCY param.
- viewItemParams.putParcelableArray(FirebaseAnalytics.Param.ITEMS, //The list of items involved in the e-commerce action. (Parcelable[]). The parameter expects a Parcelable Array set with Bundle.putParcelableArray(String, Parcelable[]):
- analytics.logEvent(FirebaseAnalytics.Event.VIEW_ITEM, viewItemParams);
Add Comment
Please, Sign In to add comment