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 | //When a user is presented with a list of results, log a view_item_list event including an items array parameter containing the displayed products. | |
| 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 | + | // product2 |
| 20 | - | var boots: [String: Any] = [ |
| 20 | + | var product2: [String: Any] = [ |
| 21 | - | AnalyticsParameterItemID: "SKU_456", |
| 21 | + | AnalyticsParameterItemID: "132337", |
| 22 | - | AnalyticsParameterItemName: "boots", |
| 22 | + | AnalyticsParameterItemName: "Beko Mašina za pranje sudova DIS26021", |
| 23 | - | AnalyticsParameterItemCategory: "shoes", |
| 23 | + | AnalyticsParameterItemCategory: "Bela tehnika", |
| 24 | - | AnalyticsParameterItemCategory2: "sub-cat1", |
| 24 | + | AnalyticsParameterItemCategory: "Mašine za pranje sudova", |
| 25 | - | AnalyticsParameterItemCategory3: "sub-cat2", |
| 25 | + | AnalyticsParameterItemCategory: "Ugradne mašine za sudove", |
| 26 | - | AnalyticsParameterItemCategory4: "sub-cat3", |
| 26 | + | AnalyticsParameterItemCategory: "item_category4", |
| 27 | - | AnalyticsParameterItemCategory5: "sub-cat4", |
| 27 | + | AnalyticsParameterItemCategory: "item_category5", |
| 28 | - | AnalyticsParameterItemVariant: "brown", |
| 28 | + | AnalyticsParameterItemVariant: "item_variant", |
| 29 | - | AnalyticsParameterItemBrand: "Google", |
| 29 | + | AnalyticsParameterItemBrand: "Beko", |
| 30 | - | AnalyticsParameterPrice: 24.99, |
| 30 | + | AnalyticsParameterPrice: 40444.00, |
| 31 | ] | |
| 32 | ||
| 33 | - | // A pair of socks (product3) |
| 33 | + | // product3 |
| 34 | - | var socks: [String: Any] = [ |
| 34 | + | var product3: [String: Any] = [ |
| 35 | - | AnalyticsParameterItemID: "SKU_789", |
| 35 | + | AnalyticsParameterItemID: "158325", |
| 36 | - | AnalyticsParameterItemName: "ankle_socks", |
| 36 | + | AnalyticsParameterItemName: "Candy Ugradna mašina za pranje sudova CDIH 1L952", |
| 37 | - | AnalyticsParameterItemCategory: "socks", |
| 37 | + | AnalyticsParameterItemCategory: "Bela tehnika", |
| 38 | - | AnalyticsParameterItemCategory2: "sub-cat1", |
| 38 | + | AnalyticsParameterItemCategory: "Mašine za pranje sudova", |
| 39 | - | AnalyticsParameterItemCategory3: "sub-cat2", |
| 39 | + | AnalyticsParameterItemCategory: "Ugradne mašine za sudove", |
| 40 | - | AnalyticsParameterItemCategory4: "sub-cat3", |
| 40 | + | AnalyticsParameterItemCategory: "item_category4", |
| 41 | - | AnalyticsParameterItemCategory5: "sub-cat4", |
| 41 | + | AnalyticsParameterItemCategory: "item_category5", |
| 42 | - | AnalyticsParameterItemVariant: "red", |
| 42 | + | AnalyticsParameterItemVariant: "item_variant", |
| 43 | - | AnalyticsParameterItemBrand: "Google", |
| 43 | + | AnalyticsParameterItemBrand: "Candy", |
| 44 | - | AnalyticsParameterPrice: 5.99, |
| 44 | + | AnalyticsParameterPrice: 40600.00, |
| 45 | ] | |
| 46 | ||
| 47 | // Add item indexes | |
| 48 | - | jeggings[AnalyticsParameterIndex] = 1 //The index of the item in a list (signed 64-bit integer as NSNumber). |
| 48 | + | product1[AnalyticsParameterIndex] = 1 //The index of the item in a list (signed 64-bit integer as NSNumber) |
| 49 | - | boots[AnalyticsParameterIndex] = 2 |
| 49 | + | product2[AnalyticsParameterIndex] = 2 |
| 50 | - | socks[AnalyticsParameterIndex] = 3 |
| 50 | + | product3[AnalyticsParameterIndex] = 3 |
| 51 | ||
| 52 | // Prepare ecommerce parameters | |
| 53 | var itemList: [String: Any] = [ | |
| 54 | - | AnalyticsParameterItemListID: "L001", //The ID of the list in which the item was presented to the user (NSString). |
| 54 | + | AnalyticsParameterItemListID: "L001", //The ID of the list in which the item was presented to the user (NSString) |
| 55 | - | AnalyticsParameterItemListName: "Related products", //The name of the list in which the item was presented to the user (NSString). |
| 55 | + | AnalyticsParameterItemListName: "Related products", //The name of the list in which the item was presented to the user (NSString) |
| 56 | ] | |
| 57 | ||
| 58 | // Add items array | |
| 59 | - | itemList[AnalyticsParameterItems] = [jeggings, boots, socks] //The list of items involved in the transaction. (NSArray). |
| 59 | + | itemList[AnalyticsParameterItems] = [product1, product2, product3] |
| 60 | ||
| 61 | // Log view item list event to firebase analytics | |
| 62 | Analytics.logEvent(AnalyticsEventViewItemList, parameters: itemList) |