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 | //To measure when a user removes a product from a cart, log the remove_from_cart event. | |
| 4 | ||
| 5 | - | // A pair of jeggings (product1) |
| 5 | + | // product1 |
| 6 | - | var jeggings: [String: Any] = [ |
| 6 | + | var product1: [String: Any] = [ |
| 7 | - | AnalyticsParameterItemID: "SKU_123", //Item ID (context-specific) (NSString). |
| 7 | + | AnalyticsParameterItemID: "183351", //Item ID (context-specific) (NSString) |
| 8 | - | AnalyticsParameterItemName: "jeggings", //Item Name (context-specific) (NSString). |
| 8 | + | AnalyticsParameterItemName: "Beko Ugradna mašina za pranje sudova DIS35023", //Item Name (context-specific) (NSString) |
| 9 | - | AnalyticsParameterItemCategory: "pants", //Item category (context-specific) (NSString). |
| 9 | + | AnalyticsParameterItemCategory: "Bela tehnika", //Item category (context-specific) (NSString) |
| 10 | - | AnalyticsParameterItemCategory2: "sub-cat1", //Item sub-category (context-specific) (NSString). |
| 10 | + | AnalyticsParameterItemCategory2: "Mašine za pranje sudova", //Item sub-category (context-specific) (NSString) |
| 11 | - | AnalyticsParameterItemCategory3: "sub-cat2", //Item sub-category (context-specific) (NSString). |
| 11 | + | AnalyticsParameterItemCategory3: "Ugradne mašine za sudove", //Item sub-category (context-specific) (NSString) |
| 12 | - | AnalyticsParameterItemCategory4: "sub-cat3", //Item sub-category (context-specific) (NSString). |
| 12 | + | AnalyticsParameterItemCategory4: "item_category4", //Item sub-category (context-specific) (NSString) |
| 13 | - | AnalyticsParameterItemCategory5: "sub-cat4", //Item sub-category (context-specific) (NSString). |
| 13 | + | AnalyticsParameterItemCategory5: "item_category5", //Item sub-category (context-specific) (NSString) |
| 14 | - | AnalyticsParameterItemVariant: "black", //Item variant (NSString). |
| 14 | + | AnalyticsParameterItemVariant: "item_variant", //Item variant (NSString) |
| 15 | - | AnalyticsParameterItemBrand: "Google", //Item brand(NSString). |
| 15 | + | AnalyticsParameterItemBrand: "Beko", //Item brand(NSString) |
| 16 | - | AnalyticsParameterPrice: 9.99, //Product price (double as NSNumber). |
| 16 | + | AnalyticsParameterPrice: 38999.00, //Product price (double as NSNumber) |
| 17 | ] | |
| 18 | ||
| 19 | - | // A pair of boots (product2) |
| 19 | + | |
| 20 | - | var boots: [String: Any] = [ |
| 20 | + | product1[AnalyticsParameterQuantity] = 1 |
| 21 | - | AnalyticsParameterItemID: "SKU_456", |
| 21 | + | |
| 22 | - | AnalyticsParameterItemName: "boots", |
| 22 | + | |
| 23 | - | AnalyticsParameterItemCategory: "shoes", |
| 23 | + | |
| 24 | - | AnalyticsParameterItemCategory2: "sub-cat1", |
| 24 | + | AnalyticsParameterCurrency: "RSD", |
| 25 | - | AnalyticsParameterItemCategory3: "sub-cat2", |
| 25 | + | AnalyticsParameterValue: 38999.00 |
| 26 | - | AnalyticsParameterItemCategory4: "sub-cat3", |
| 26 | + | |
| 27 | - | AnalyticsParameterItemCategory5: "sub-cat4", |
| 27 | + | |
| 28 | - | AnalyticsParameterItemVariant: "brown", |
| 28 | + | |
| 29 | - | AnalyticsParameterItemBrand: "Google", |
| 29 | + | removeParams[AnalyticsParameterItems] = [product1] |
| 30 | - | AnalyticsParameterPrice: 24.99, |
| 30 | + | |
| 31 | // Log removal event | |
| 32 | Analytics.logEvent(AnalyticsEventRemoveFromCart, parameters: removeParams) |