ECommerce class

Methods of this class create an ECommerce instance.

For different user actions, there are appropriate types of E-commerce events. To create a specific event type, use the appropriate class method.

Note

You can send the ECommerce instance using the reportECommerce(_:onFailure:) method of the AppMetrica class and the AppMetricaReporting protocol.

Instance methods

showScreenEvent(screen:)

Creates an E-commerce event called ShowScreenEvent. Use it to report the opening of a page, such as a list of products, search or home page.

showProductCardEvent(product:screen:)

Creates an E-commerce event called ShowProductCardEvent. Use it to report viewing a product profile among others on the list.

showProductDetailsEvent(product:referrer:)

Creates an E-commerce event called ShowProductDetailsEvent. Use it to report viewing a product page.

addCartItemEvent(cartItem:)

Creates an E-commerce event called AddCartItemEvent. Use it to report adding an item to the cart.

removeCartItemEvent(cartItem:)

Creates an E-commerce event called RemoveCartItemEvent. Use it to report removing an item from the cart.

beginCheckoutEvent(order:)

Creates an E-commerce event called BeginCheckoutEvent. Use it to report starting a purchase.

purchaseEvent(order:)

Creates an E-commerce event called PurchaseEvent. Use it to report a completed purchase.

Method descriptions

showScreenEvent(screen:)

static func showScreenEvent(screen: ECommerceScreen) -> ECommerce

Creates an E-commerce event called ShowScreenEvent. Use it to report the opening of a page, such as a list of products, search or home page.

Parameters:

screen

The screen that was opened. The ECommerceScreen class instance.

Returns:

The ECommerce class instance.

showProductCardEvent(product:screen:)

static func showProductCardEvent(product: ECommerceProduct,  screen: ECommerceScreen) -> ECommerce

Creates an E-commerce event called ShowProductCardEvent. Use it to report viewing a product profile among others on the list.

Note

Before sending the event, make sure that the product profile was shown on the screen for more than N seconds.

Parameters:

product

The product that was shown. The ECommerceProduct class instance.

screen

The screen where the product was displayed. The ECommerceScreen class instance.

Returns:

The ECommerce class instance.

showProductDetailsEvent(product:referrer:)

static func showProductDetailsEvent(product: ECommerceProduct, referrer: ECommerceReferrer?) -> ECommerce

Creates an E-commerce event called ShowProductDetailsEvent. Use it to report viewing a product page.

Parameters:

product

The product that was shown. The ECommerceProduct class instance.

referrer

Information about the source of traffic to the product page. The ECommerceReferrer class instance.

Returns:

The ECommerce class instance.

addCartItemEvent(cartItem:)

static func addCartItemEvent(cartItem: ECommerceCartItem) -> ECommerce

Creates an E-commerce event called AddCartItemEvent. Use it to report adding an item to the cart.

Parameters:

item

The item that was added to the cart. The ECommerceCartItem class instance.

Returns:

The ECommerce class instance.

removeCartItemEvent(cartItem:)

static func removeCartItemEvent(cartItem: ECommerceCartItem) -> ECommerce

Creates an E-commerce event called RemoveCartItemEvent. Use it to report removing an item from the cart.

Parameters:

item

The item that was removed from the cart. The ECommerceCartItem class instance.

Returns:

The ECommerce class instance.

beginCheckoutEvent(order:)

static func beginCheckoutEvent(order: ECommerceOrder) -> ECommerce

Creates an E-commerce event called BeginCheckoutEvent. Use it to report starting a purchase.

Parameters:

order

Information about the purchase. The ECommerceOrder class instance.

Returns:

The ECommerce class instance.

purchaseEvent(order:)

static func purchaseEvent(order: ECommerceOrder) -> ECommerce

Creates an E-commerce event called PurchaseEvent. Use it to report a completed purchase.

Parameters:

order

Information about the purchase. The ECommerceOrder class instance.

Returns:

The ECommerce class instance.