Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Products can be instrumented as an array of items that can be added to prescribed ecommerce events.
- //Once a user selects a particular product from the list, log a select_item event with the chosen product in an items array parameter.
- // A pair of jeggings (product1)
- var jeggings: [String: Any] = [
- AnalyticsParameterItemID: "SKU_123", //Item ID (context-specific) (NSString).
- AnalyticsParameterItemName: "jeggings", //Item Name (context-specific) (NSString).
- AnalyticsParameterItemCategory: "pants", //Item category (context-specific) (NSString).
- AnalyticsParameterItemCategory2: "sub-cat1", //Item sub-category (context-specific) (NSString).
- AnalyticsParameterItemCategory3: "sub-cat2", //Item sub-category (context-specific) (NSString).
- AnalyticsParameterItemCategory4: "sub-cat3", //Item sub-category (context-specific) (NSString).
- AnalyticsParameterItemCategory5: "sub-cat4", //Item sub-category (context-specific) (NSString).
- AnalyticsParameterItemVariant: "black", //Item variant (NSString).
- AnalyticsParameterItemBrand: "Google", //Item brand (NSString).
- AnalyticsParameterPrice: 9.99, //Product price (double as NSNumber).
- ]
- // Prepare ecommerce parameters
- var selectedItem: [String: Any] = [
- AnalyticsParameterItemListID: "L001", //The ID of the list in which the item was presented to the user (NSString).
- AnalyticsParameterItemListName: "Related products", //The name of the list in which the item was presented to the user (NSString).
- ]
- // Add items array for selected product (for example, jeggings)
- selectedItem[AnalyticsParameterItems] = [jeggings] //The list of items involved in the transaction. (NSArray).
- // Log select item event to Firebase Analytics
- Analytics.logEvent(AnalyticsEventSelectItem, parameters: selectedItem)
Advertisement
Add Comment
Please, Sign In to add comment