iOS Ecommerce Activity Tracking

This e-commerce documentation helps define the journey for a customer as they visit a product page or a product category page, add a product to wishlist, update a shopping cart, create or update an order.

Here is a list of supported events:

Event typeDescription
productViewedTrack a product card a user is viewing to rank items / categories and send triggers for abandoned browses.
productCategoryViewedTrack a product category a user is viewing for triggers like Website visit with a category view and Website visit without a category view.
productAddedToWishlistTrack adding product to a wishlist to calculate and display recoms and send triggers related to a wishlist.
cartUpdatedTrack updating a shopping cart for triggers.
orderCreatedCreate an order.
orderUpdatedUpdate an order.
orderDeliveredChange an existing order status to DELIVERED.
orderCancelledChange an existing order status to CANCELLED.
searchRequestTrack search requests for triggers like Abandoned search.

Track activity via Reteno.ecommerce().logEvent(type: Ecommerce.EventType, date: Date, forcePush: Bool) method. Provide appropriate event type, event date and forcePush flag (if you want to send event immediatelly).

Product Viewed

Fire this event when a user views a product card.

This event supports the following properties:

ParameterTypeComment
productEcommerce.ProductRequired parameter
currencyCodeString?Currency in ISO 4217 format. Supported currencies: USD, EUR, UAH. If is not set then org's default is used

Example:

let product = Ecommerce.Product(
    productId: "Product_ID",
    price: 20.0,
    isInStock: 1,
    attributes: ["size": ["23", "42"], "color": ["white", "orange"]]
)
Reteno.ecommerce().logEvent(type: .productViewed(product: product, currencyCode: "UAH"))

Product Category Viewed

Fire this event when a user views a category.

This event supports the following properties:

ParameterTypeComment
categoryEcommerce.ProductCategoryRequired parameter

Example:

let productCategory = Ecommerce.ProductCategory(
    productCategoryId: "CATEGORY_ID",
    attributes: ["size": ["M", "L"]]
)
Reteno.ecommerce().logEvent(type: .productCategoryViewed(category: productCategory))

Product Added to Wishlist

Fire this event when a user adds a product to a wishlist.

This event supports the following properties:

ParameterTypeComment
productEcommerce.ProductRequired parameter
currencyCodeString?Currency in ISO 4217 format. Supported currencies: USD, EUR, UAH. If is not set then org's default is used

Example:

let product = Ecommerce.Product(
    productId: "PRODUCT_ID",
    price: 20.0,
    isInStock: 1,
    attributes: ["size": ["23", "42"], "color": ["white", "orange"]]
)
Reteno.ecommerce().logEvent(type: .productAddedToWishlist(product: product, currencyCode: "EUR"))

Cart Updated

Fire this event when a user updates a shopping cart.

The cartUpdated event transmits not the fact of adding a specific product to the cart, but the current state of the cart. If the first product is added to the cart, then an array with one product is passed in the cartUpdated event. If a second, third, etc. product is added, then an array of two, three, etc. products is transmitted in the cartUpdated events. The same logic works when removing products from the cart.

In each cartUpdated event, the cartId parameter must be passed. This is a unique identifier of the current state of the cart. Each time you send the cartUpdated event, you must pass a new cartId value that will be different from the previous ones.

This event supports the following properties:

ParameterTypeComment
cartIdStringRequired parameter
productsArray of Ecommerce.ProductInCartRequired parameter
currencyCodeString?Currency in ISO 4217 format. Supported currencies: USD, EUR, UAH. If is not set then org's default is used

Ecommerce.ProductInCart model parameters:

ParameterTypeComment
productIdStringProduct ID (required).
priceFloatProduct price (required).
quantityIntProduct quantity (required).
discountFloat?Disount
nameString?Product name
categoryString?Product category
attributes[String: [String]]?Additional attributes, for example, ["size": ["23", "42"], "color": ["white", "orange"]]

Example:

let productsInCart = [
    Ecommerce.ProductInCart(productId: "uut", price: 20.0, quantity: 1),
    Ecommerce.ProductInCart(productId: "lk", price: 100.0, quantity: 3)
]
Reteno.ecommerce().logEvent(type: .cartUpdated(cartId: "CART_ID", products: productsInCart, currencyCode: "UAH"))

Order Сreated

Fire this event when a user creates an order.

This event supports the following properties:

ParameterTypeComment
orderEcommerce.OrderRequired parameter
currencyCodeString?Currency in ISO 4217 format. Supported currencies: USD, EUR, UAH. If is not set then org's default is used

Ecommerce.Order model parameters:

ParameterTypeComment
externalOrderIdStringID of order in the external system (required).
totalCostFloatTotal cost of order (required).
statusStatusOrder status (required). Possible values: DELIVERED, IN_PROGRESS, CANCELLED, INITIALIZED. Only DELIVERED orders are used in RFM analysis.
dateDateOrder date and time (required).
cartIdString?Shopping cart ID. Allows to match an order with shopping cart actions.
emailString?Customer email address.
phoneString?Customer phone number.
firstNameString?Customer first name.
lastNameString?Customer last name.
shippingFloat?Shipping cost.
discountFloat?Discount.
taxesFloat?Amount of tax.
restoreUrlString?Link to order.
statusDescriptionString?Order status description.
storeIdString?Store ID (if you work with several stores in one eSputnik account).
sourceString?"Online" \ "offline" values for segmentation. If the field is empty or some other value, by default the order will be accepted as online.
deliveryMethodString?Delivery method.
paymentMethodString?Payment method.
deliveryAddressString?Delivery address.
items[Item]?Array of ordered products (required).
attributes[String: [String: Any]]?Additional attributes. Provide additional parameter name as key and parameter JSON as value.

Ecommerce.Order.Item model parameters:

ParameterTypeComment
externalItemIdStringID of product in the external system (required).
nameStringProduct name (required).
categoryStringProduct category (required).
quantityDoubleNumber of items (required).
costFloatProduct price (required).
urlStringLink to product page (required).
imageUrlString?Link to a product image.
descriptionString?Short description of product.

Example:

let order = Ecommerce.Order(
    externalOrderId: "ORDER_ID",
    totalCost: 300.0,
    status: .INITIALIZED,
    date: Date(),
    cartId: "idid"
)
Reteno.ecommerce().logEvent(type: .orderCreated(order: order, currencyCode: "UAH"))

Order Updated

Fire this event when a user updates an order.

This event supports the following properties:

ParameterTypeComment
orderEcommerce.OrderRequired parameter
currencyCodeString?Currency in ISO 4217 format. Supported currencies: USD, EUR, UAH. If is not set then org's default is used

Ecommerce.Order and Ecommerce.Order.Item models parameters are described in Order created event.

Example:

let order = Ecommerce.Order(
    externalOrderId: "ORDER_ID",
    totalCost: 300.0,
    status: .IN_PROGRESS,
    date: Date(),
    cartId: "idid"
)
Reteno.ecommerce().logEvent(type: .orderUpdated(order: order, currencyCode: "UAH"))

Order Delivered

Fire this event when an order status is changed to delivered. If an order does not exist then an event is ignored.

This event supports the following properties:

ParameterTypeComment
externalOrderIdStringRequired parameter

Example:

Reteno.ecommerce().logEvent(type: .orderDelivered(externalOrderId: "ORDER_ID"))

Order Cancelled

Fire this event when an order status is changed to cancelled. If an order does not exist then an event is ignored.

This event supports the following properties:

ParameterTypeComment
externalOrderIdStringRequired parameter

Example:

Reteno.ecommerce().logEvent(type: .orderCancelled(externalOrderId: "ORDER_ID"))

Search Request

This event supports the following properties:

ParameterTypeComment
queryStringRequired. Order ID in external system
isFoundBool?Flag if search returned results

Example:

Reteno.ecommerce().logEvent(type: .searchRequest(query: "iphone", isFound: true))

Unsupported Events

If you want to track user activity and could not find appropriate Ecommerce.EventType, you always can use Reteno.logEvent method:

Reteno.logEvent(
    eventTypeKey: "test_event_type",
    date: Date(),
    parameters: [Event.Parameter(name: "Parameter name", value: "some parameter value")],
    forcePush: false
)