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 | //Once a user selects a particular product from the list, log a select_item event with the chosen product in an items array parameter. | |
| 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 | // Prepare ecommerce parameters | |
| 20 | var selectedItem: [String: Any] = [ | |
| 21 | AnalyticsParameterItemListID: "L001", //The ID of the list in which the item was presented to the user (NSString). | |
| 22 | AnalyticsParameterItemListName: "Related products", //The name of the list in which the item was presented to the user (NSString). | |
| 23 | ] | |
| 24 | ||
| 25 | - | // Add items array for selected product (for example, jeggings) |
| 25 | + | // Add items array for the selected product |
| 26 | - | selectedItem[AnalyticsParameterItems] = [jeggings] //The list of items involved in the transaction. (NSArray). |
| 26 | + | selectedItem[AnalyticsParameterItems] = [product1] //The list of items involved in the transaction. (NSArray). |
| 27 | ||
| 28 | - | // Log select item event to Firebase Analytics |
| 28 | + | // Log select item event |
| 29 | Analytics.logEvent(AnalyticsEventSelectItem, parameters: selectedItem) |