MPCommerceEvent Class Reference

Inherits from NSObject
Conforms to NSCopying
NSSecureCoding
Declared in MPCommerceEvent.h
MPCommerceEvent.mm

Overview

This class contains the information and represents a commerce event to be logged using the mParticle SDK.

Usage:

Swift


let commerceEvent = MPCommerceEvent(action: MPCommerceEventAction.AddToCart, product: product1)

let mParticle = MParticle.sharedInstance()

mParticle.logCommerceEvent(commerceEvent)

Objective-C


MPCommerceEvent *commerceEvent = [[MPCommerceEvent alloc] initWithAction:MPCommerceEventActionAddToCart product:product1];

MParticle *mParticle = [MParticle sharedInstance];

[mParticle logCommerceEvent:commerceEvent];

  checkoutOptions

Checkout option string describing what the options are.

@property (nonatomic, strong, nullable) NSString *checkoutOptions

Discussion

Checkout option string describing what the options are.

Declared In

MPCommerceEvent.h

  currency

The currency used in the commerce event.

@property (nonatomic, strong, nullable) NSString *currency

Discussion

The currency used in the commerce event.

Declared In

MPCommerceEvent.h

  impressions

A dictionary containing list names as keys and arrays of products impressed under that list name

@property (nonatomic, strong, readonly, nullable) NSDictionary<NSString*__kindofNSSet<MPProduct*> *> *impressions

Discussion

A dictionary containing list names as keys and arrays of products impressed under that list name


{"listName1":[product1, product2]}

Declared In

MPCommerceEvent.h

  products

List of products being applied action

@property (nonatomic, strong, readonly, nullable) NSArray<MPProduct*> *products

Discussion

List of products being applied action

Declared In

MPCommerceEvent.h

  promotionContainer

A promotion container describing a promotion action and its respective products.

@property (nonatomic, strong, nullable) MPPromotionContainer *promotionContainer

Discussion

A promotion container describing a promotion action and its respective products.

Declared In

MPCommerceEvent.h

  productListName

Describes a product action list for this commerce event transaction.

@property (nonatomic, strong, nullable) NSString *productListName

Discussion

Describes a product action list for this commerce event transaction.

Declared In

MPCommerceEvent.h

  productListSource

Describes a product list source for this commerce event transaction.

@property (nonatomic, strong, nullable) NSString *productListSource

Discussion

Describes a product list source for this commerce event transaction.

Declared In

MPCommerceEvent.h

  screenName

The label describing the screen on which the commerce event transaction occurred

@property (nonatomic, strong, nullable) NSString *screenName

Discussion

The label describing the screen on which the commerce event transaction occurred

Declared In

MPCommerceEvent.h

  transactionAttributes

The attributes of the transaction, such as: transactionId, tax, affiliation, shipping, etc.

@property (nonatomic, strong, nullable) MPTransactionAttributes *transactionAttributes

Discussion

The attributes of the transaction, such as: transactionId, tax, affiliation, shipping, etc.

Declared In

MPCommerceEvent.h

  customFlags

Custom flags are a collection of attributes used to trigger functionality in specific integrations. By default, most integrations will ignore custom flags. Reference the documentation for your integrations to see if they make use of custom flags.

@property (nonatomic, strong, readonly, nonnull) NSDictionary<NSString*__kindofNSArray<NSString*> *> *customFlags

Discussion

Custom flags are a collection of attributes used to trigger functionality in specific integrations. By default, most integrations will ignore custom flags. Reference the documentation for your integrations to see if they make use of custom flags.

Declared In

MPCommerceEvent.h

  action

A value from the MPCommerceEventAction enum describing the commerce event action.

@property (nonatomic, unsafe_unretained) MPCommerceEventAction action

Discussion

A value from the MPCommerceEventAction enum describing the commerce event action.

Declared In

MPCommerceEvent.h

  checkoutStep

The step number, within the chain of commerce event transactions, corresponding to the checkout.

@property (nonatomic, unsafe_unretained) NSInteger checkoutStep

Discussion

The step number, within the chain of commerce event transactions, corresponding to the checkout.

Declared In

MPCommerceEvent.h

  nonInteractive

Flag indicating whether a refund is non-interactive. The default value is false/NO.

@property (nonatomic, unsafe_unretained) BOOL nonInteractive

Discussion

Flag indicating whether a refund is non-interactive. The default value is false/NO.

Declared In

MPCommerceEvent.h

– initWithAction:product:

Initializes an instance of MPCommerceEvent with an action and a product.

- (nonnull instancetype)initWithAction:(MPCommerceEventAction)action product:(nullable MPProduct *)product

Parameters

action

A value from the MPCommerceEventAction enum describing the commerce event action

product

An instance of MPProduct

Discussion

Initializes an instance of MPCommerceEvent with an action and a product.

Declared In

MPCommerceEvent.h

– initWithImpressionName:product:

Initializes an instance of MPCommerceEvent with a list name for a product impression.

- (nonnull instancetype)initWithImpressionName:(nullable NSString *)listName product:(nullable MPProduct *)product

Parameters

listName

A string under which the product was listed for this impression

product

An instance of MPProduct

Discussion

Initializes an instance of MPCommerceEvent with a list name for a product impression.

Declared In

MPCommerceEvent.h

– initWithPromotionContainer:

Initializes an instance of MPCommerceEvent with a promotion container (promotion for products).

- (nonnull instancetype)initWithPromotionContainer:(nullable MPPromotionContainer *)promotionContainer

Parameters

promotionContainer

An instance of MPPromotionContainer describing a promotion action and its respective products

Discussion

Initializes an instance of MPCommerceEvent with a promotion container (promotion for products).

Declared In

MPCommerceEvent.h

– addImpression:listName:

Adds the representation of a product impression under a given list name.

- (void)addImpression:(nonnull MPProduct *)product listName:(nonnull NSString *)listName

Parameters

product

An instance of MPProduct

listName

A string under which the product was listed for this impression

Discussion

Adds the representation of a product impression under a given list name.

Declared In

MPCommerceEvent.h

– addProduct:

Adds a product to the list of products to have action applied to.

- (void)addProduct:(nonnull MPProduct *)product

Parameters

product

An instance of MPProduct

Discussion

Adds a product to the list of products to have action applied to.

Declared In

MPCommerceEvent.h

– removeProduct:

Removes a product from the list of products to have action applied to.

- (void)removeProduct:(nonnull MPProduct *)product

Parameters

product

An instance of MPProduct

Discussion

Removes a product from the list of products to have action applied to.

Declared In

MPCommerceEvent.h

– setCustomAttributes:

Associates a custom dictionary of key/value pairs to the commerce event.

- (void)setCustomAttributes:(nullable NSDictionary<NSString*,NSString*> *)customAttributes

Parameters

customAttributes

A dictionary containing the custom key/value pairs.

Discussion

Associates a custom dictionary of key/value pairs to the commerce event.

Alternatively you can set custom attributes using the regular notation for setting key/value pairs in an NSMutableDictionary.

For example:

Swift


let commerceEvent = MPCommerceEvent(action: MPCommerceEventAction.AddToCart, product: product1)

commerceEvent.setCustomAttributes(dictionaryOfKeyValuePairs)

commerceEvent["Custom Key"] = "Custom Value"

Objective-C


MPCommerceEvent *commerceEvent = [[MPCommerceEvent alloc] initWithAction:MPCommerceEventActionAddToCart product:product1];

[commerceEvent setCustomAttributes:dictionaryOfKeyValuePairs];

commerceEvent[@"Custom Key"] = @"Custom Value";

Declared In

MPCommerceEvent.h

– allKeys

Returns an array with all keys in the custom attributes dictionary

- (nullable NSArray *)allKeys

Return Value

An array with all keys in the custom attributes dictionary

Discussion

Returns an array with all keys in the custom attributes dictionary

Declared In

MPCommerceEvent.h

– addCustomFlag:withKey:

Adds a custom flag associated with a key to the event.

- (void)addCustomFlag:(nonnull NSString *)customFlag withKey:(nonnull NSString *)key

Parameters

customFlag

A string attribute

key

The key associated with the custom flag.

Discussion

Adds a custom flag associated with a key to the event.

Declared In

MPCommerceEvent.h

– addCustomFlags:withKey:

Adds an array of custom flags associated with a key to the event.

- (void)addCustomFlags:(nonnull NSArray<NSString*> *)customFlags withKey:(nonnull NSString *)key

Parameters

customFlags

An array of string attributes

key

The key associated with the custom flags.

Discussion

Adds an array of custom flags associated with a key to the event.

Declared In

MPCommerceEvent.h