logAddToCart method

Future<void> logAddToCart({
  1. required String itemId,
  2. required String itemName,
  3. required String itemCategory,
  4. required int quantity,
  5. double? price,
  6. double? value,
  7. String? currency,
  8. String? origin,
  9. String? itemLocationId,
  10. String? destination,
  11. String? startDate,
  12. String? endDate,
})

Logs the standard add_to_cart event.

This event signifies that an item was added to a cart for purchase. Add this event to a funnel with logEcommercePurchase to gauge the effectiveness of your checkout process. Note: If you supply the value parameter, you must also supply the currency parameter so that revenue metrics can be computed accurately.

See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#ADD_TO_CART

Implementation

Future<void> logAddToCart({
  required String itemId,
  required String itemName,
  required String itemCategory,
  required int quantity,
  double? price,
  double? value,
  String? currency,
  String? origin,
  String? itemLocationId,
  String? destination,
  String? startDate,
  String? endDate,
}) {
  _requireValueAndCurrencyTogether(value, currency);

  return logEvent(
    name: 'add_to_cart',
    parameters: filterOutNulls(<String, Object?>{
      _ITEM_ID: itemId,
      _ITEM_NAME: itemName,
      _ITEM_CATEGORY: itemCategory,
      _QUANTITY: quantity,
      _PRICE: price,
      _VALUE: value,
      _CURRENCY: currency,
      _ORIGIN: origin,
      _ITEM_LOCATION_ID: itemLocationId,
      _DESTINATION: destination,
      _START_DATE: startDate,
      _END_DATE: endDate,
    }),
  );
}