Flutter Firebase Analytics 电子商务购买

Flutter Firebase Analytics Ecommerce Purchase

Future<void> logEcommercePurchase ( {String currency, double value, String transactionId, double tax, double shipping, String coupon, String location, int numberOfNights, int numberOfRooms, int numberOfPassengers, String origin, String destination, String startDate, String endDate, String travelClass} )

如何使用此 API 记录单件商品的购买?几天来我一直在四处寻找并尝试各种方法,例如在记录电子商务购买之前将商品添加到购物车,但它不起作用。帮忙!

https://pub.dev/documentation/firebase_analytics/latest/firebase_analytics/FirebaseAnalytics/logEcommercePurchase.html

看来 flutterfire 还是用一个老事件来追踪这个,我不知道为什么只追踪酒店房间的购买。

Here 他们提到它已被弃用,您应该使用 purchase 事件。我还没有测试过,但你可以试试这样的东西:

const data = {
             transaction_id: 'T)ID',
             value: 1.00,
             currency: 'USD',
             tax: 0,
             shipping: 0,
             coupon: '',
             items: [{
                     item_id: 'I_ID',
                     item_name: 'I_NAME',
                     item_list_name: 'IL_NAME',
                     item_list_id: 'IL_ID',
                     item_brand: 'I_B',
                     item_category: 'I_C',
                     item_variant: 'I_V',
                     quantity: 1,
                     price: 1,
                     }]
               }
                    
await analytics().logEvent('purchase', data)