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 | //Measure a product being added to a wishlist by logging an add_to_wishlist event with the relevant products in an items array parameter. | |
| 4 | ||
| 5 | // product1 | |
| 6 | - | // A pair of jeggings (product1) |
| 6 | + | var product1: [String: Any] = [ |
| 7 | - | var jeggings: [String: Any] = [ |
| 7 | + | AnalyticsParameterItemID: "183351", //Item ID (context-specific) (NSString) |
| 8 | - | AnalyticsParameterItemID: "SKU_123", //Item ID (context-specific) (NSString). |
| 8 | + | AnalyticsParameterItemName: "Beko Ugradna mašina za pranje sudova DIS35023", //Item Name (context-specific) (NSString) |
| 9 | - | AnalyticsParameterItemName: "jeggings", //Item Name (context-specific) (NSString). |
| 9 | + | AnalyticsParameterItemCategory: "Bela tehnika", //Item category (context-specific) (NSString) |
| 10 | - | AnalyticsParameterItemCategory: "pants", //Item category (context-specific) (NSString). |
| 10 | + | AnalyticsParameterItemCategory2: "Mašine za pranje sudova", //Item sub-category (context-specific) (NSString) |
| 11 | - | AnalyticsParameterItemCategory2: "sub-cat1", //Item sub-category (context-specific) (NSString). |
| 11 | + | AnalyticsParameterItemCategory3: "Ugradne mašine za sudove", //Item sub-category (context-specific) (NSString) |
| 12 | - | AnalyticsParameterItemCategory3: "sub-cat2", //Item sub-category (context-specific) (NSString). |
| 12 | + | AnalyticsParameterItemCategory4: "item_category4", //Item sub-category (context-specific) (NSString) |
| 13 | - | AnalyticsParameterItemCategory4: "sub-cat3", //Item sub-category (context-specific) (NSString). |
| 13 | + | AnalyticsParameterItemCategory5: "item_category5", //Item sub-category (context-specific) (NSString) |
| 14 | - | AnalyticsParameterItemCategory5: "sub-cat4", //Item sub-category (context-specific) (NSString). |
| 14 | + | AnalyticsParameterItemVariant: "item_variant", //Item variant (NSString) |
| 15 | - | AnalyticsParameterItemVariant: "black", //Item variant (NSString). |
| 15 | + | AnalyticsParameterItemBrand: "Beko", //Item brand(NSString) |
| 16 | - | AnalyticsParameterItemBrand: "Google", //Item brand (NSString). |
| 16 | + | AnalyticsParameterPrice: 38999.00, //Product price (double as NSNumber) |
| 17 | - | AnalyticsParameterPrice: 9.99, //Product price (double as NSNumber). |
| 17 | + | |
| 18 | ||
| 19 | // Specify order quantity | |
| 20 | product1[AnalyticsParameterQuantity] = 2 //Product quantity (signed 64-bit integer as NSNumber). | |
| 21 | - | jeggings[AnalyticsParameterQuantity] = 2 //Product quantity (signed 64-bit integer as NSNumber). |
| 21 | + | |
| 22 | // Prepare item detail params | |
| 23 | var itemDetails: [String: Any] = [ | |
| 24 | AnalyticsParameterCurrency: "RSD", //Currency of the product or items associated with the event, in 3-letter ISO_4217 format (NSString). | |
| 25 | - | AnalyticsParameterCurrency: "USD", //Currency of the product or items associated with the event, in 3-letter ISO_4217 format (NSString). |
| 25 | + | AnalyticsParameterValue: 38999.00 //A context-specific numeric value which is accumulated automatically for each event type. |
| 26 | - | AnalyticsParameterValue: 19.98 //A context-specific numeric value which is accumulated automatically for each event type. |
| 26 | + | |
| 27 | ||
| 28 | // Add items | |
| 29 | itemDetails[AnalyticsParameterItems] = [product1] //The list of items involved in the e-commerce action. (NSArray). | |
| 30 | - | itemDetails[AnalyticsParameterItems] = [jeggings] //The list of items involved in the e-commerce action. (NSArray). |
| 30 | + | |
| 31 | // Log an event when product is added to wishlist | |
| 32 | Analytics.logEvent(AnalyticsEventAddToWishlist, parameters: itemDetails) |