SHOW:
|
|
- or go back to the newest paste.
| 1 | // Products can be instrumented as an array of items that can be added to prescribed ecommerce events. | |
| 2 | ||
| 3 | - | //Log add_payment_info when a user submits their payment information. If applicable, include payment_type with this event for the chosen method of payment. |
| 3 | + | //Measure a purchase by logging a purchase event with one or more items defined with the relevant fields. |
| 4 | ||
| 5 | // product1 | |
| 6 | var product1: [String: Any] = [ | |
| 7 | AnalyticsParameterItemID: "183351", //Item ID (context-specific) (NSString) | |
| 8 | AnalyticsParameterItemName: "Beko Ugradna mašina za pranje sudova DIS35023", //Item Name (context-specific) (NSString) | |
| 9 | AnalyticsParameterItemCategory: "Bela tehnika", //Item category (context-specific) (NSString) | |
| 10 | AnalyticsParameterItemCategory2: "Mašine za pranje sudova", //Item sub-category (context-specific) (NSString) | |
| 11 | AnalyticsParameterItemCategory3: "Ugradne mašine za sudove", //Item sub-category (context-specific) (NSString) | |
| 12 | AnalyticsParameterItemCategory4: "item_category4", //Item sub-category (context-specific) (NSString) | |
| 13 | AnalyticsParameterItemCategory5: "item_category5", //Item sub-category (context-specific) (NSString) | |
| 14 | AnalyticsParameterItemVariant: "item_variant", //Item variant (NSString) | |
| 15 | AnalyticsParameterItemBrand: "Beko", //Item brand(NSString) | |
| 16 | AnalyticsParameterPrice: 38999.00, //Product price (double as NSNumber) | |
| 17 | ] | |
| 18 | ||
| 19 | // product2 | |
| 20 | var product2: [String: Any] = [ | |
| 21 | AnalyticsParameterItemID: "132337", | |
| 22 | AnalyticsParameterItemName: "Beko Mašina za pranje sudova DIS26021", | |
| 23 | AnalyticsParameterItemCategory: "Bela tehnika", | |
| 24 | AnalyticsParameterItemCategory: "Mašine za pranje sudova", | |
| 25 | AnalyticsParameterItemCategory: "Ugradne mašine za sudove", | |
| 26 | AnalyticsParameterItemCategory: "item_category4", | |
| 27 | AnalyticsParameterItemCategory: "item_category5", | |
| 28 | AnalyticsParameterItemVariant: "item_variant", | |
| 29 | AnalyticsParameterItemBrand: "Beko", | |
| 30 | AnalyticsParameterPrice: 40444.00, | |
| 31 | ] | |
| 32 | ||
| 33 | - | // Specify payment quantity |
| 33 | + | // Specify purchase quantity |
| 34 | product1[AnalyticsParameterQuantity] = 2 | |
| 35 | product2[AnalyticsParameterQuantity] = 1 | |
| 36 | ||
| 37 | - | // Prepare payment params |
| 37 | + | // Prepare purchase params |
| 38 | - | var paymentParams: [String: Any] = [ |
| 38 | + | var purchaseParams: [String: Any] = [ |
| 39 | - | AnalyticsParameterCurrency: "RSD", |
| 39 | + | AnalyticsParameterTransactionID: "T12345", //The unique identifier of the transaction (NSString). |
| 40 | - | AnalyticsParameterValue: 118442.00, |
| 40 | + | AnalyticsParameterAffiliation: "affiliation", //Optional. A product affiliation to designate a supplying company or brick and mortar store location (NSString). |
| 41 | - | AnalyticsParameterCoupon: "SUMMER_FUN", |
| 41 | + | AnalyticsParameterCurrency: "RSD", //Currency of the purchase or items associated with the event, in 3-letter ISO_4217 format (NSString). |
| 42 | - | AnalyticsParameterPaymentType: "Card" //The chosen method of payment (NSString). |
| 42 | + | AnalyticsParameterValue: 118442.00, //Value should be specified as signed 64-bit integer or double as NSNumber. |
| 43 | AnalyticsParameterTax: 19744.28, //Tax cost associated with a transaction (double as NSNumber). | |
| 44 | AnalyticsParameterShipping: 0.00, //Shipping cost associated with a transaction (double as NSNumber). | |
| 45 | AnalyticsParameterCoupon: "SUMMER_FUN" | |
| 46 | - | paymentParams[AnalyticsParameterItems] = [product1, product2] |
| 46 | + | |
| 47 | ||
| 48 | - | // Log added payment info event |
| 48 | + | |
| 49 | - | Analytics.logEvent(AnalyticsEventAddPaymentInfo, parameters: paymentParams) |
| 49 | + | purchaseParams[AnalyticsParameterItems] = [product1, product2] |
| 50 | ||
| 51 | // Log purchase event | |
| 52 | Analytics.logEvent(AnalyticsEventPurchase, parameters: purchaseParams) |