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.
- //To measure how many times product details are viewed, log a view_item event whenever a user views a product’s details screen.
- // 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 productDetails: [String: Any] = [
- AnalyticsParameterCurrency: "USD", //Currency of the product or items associated with the event, in 3-letter ISO_4217 format (NSString).
- AnalyticsParameterValue: 9.99 //A context-specific numeric value which is accumulated automatically for each event type.
- ]
- // Add items array
- productDetails[AnalyticsParameterItems] = [jeggings] //The list of items involved in the e-commerce action. (NSArray).
- // Log view item event
- Analytics.logEvent(AnalyticsEventViewItem, parameters: productDetails)
Advertisement
Add Comment
Please, Sign In to add comment