RemoveFromCartEvent is part of the Salesforce Marketing Cloud Unified SDK’s event tracking system for e-commerce applications. This event should be tracked when a user removes one or more items from their shopping cart. The event extends CartEvent and inherits all cart-related event functionality.
Properties
Inherited from CartEvent
lineItems
1val lineItems: List<LineItem>
A list of line items representing the items being removed from the cart. Each line item describes a purchasable catalog object with quantity and optional pricing information.
Inherited from EngagementEvent
category
1open override var category: Event.Category
The Event category name. Contains a list of allowed values that classify the event type.
priority
1open override val priority: Priority
Defines the priority level of the event for processing and handling by the SDK.
Methods
Inherited from EngagementEvent
attributes()
1open override fun attributes(): Map<String, Any>
Returns the event attributes as a map of key-value pairs associated with this event.
Returns:Map<String, Any> - A map containing the event attributes
name()
1open override fun name(): String
Returns the name for the event. This value must match the Event Name used when creating the event in the Marketing Cloud UI for any action to result from tracking this event.
Returns:String - The event name
Related Classes
LineItem
Line items describe purchasable items for Cart and Order events.
1data class LineItem @JvmOverloads constructor(2 val catalogObjectType: String,3 val catalogObjectId: String,4 val quantity: Int,5 var price: Double? = null,6 var currency: String? = null,7 var attributes: Map<String, Any> = mapOf()8)
LineItem Parameters
Parameter
Type
Required
Default
Description
catalogObjectType
String
Yes
-
Type name for the referenced catalog object
catalogObjectId
String
Yes
-
Unique identifier for the referenced catalog object
quantity
Int
Yes
-
Number of catalog objects in the line item
price
Double?
No
null
Price of the referenced catalog object
currency
String?
No
null
Currency code for the price field
attributes
Map<String, Any>
No
mapOf()
User-supplied key-value pairs
Usage
To track when items are removed from a cart, create a RemoveFromCartEvent with the appropriate line items and track it using the SDK’s event tracking system.
Example
1// Create line items for products being removed2val lineItem1 = LineItem(3 catalogObjectType = "Product",4 catalogObjectId = "product_123",5 quantity = 1,6 price = 29.99,7 currency = "USD"8)910val lineItem2 = LineItem(11 catalogObjectType = "Product",12 catalogObjectId = "product_456",13 quantity = 2,14 price = 15.50,15 currency = "USD"16)1718// Create the remove from cart event19val removeEvent = RemoveFromCartEvent(listOf(lineItem1, lineItem2))2021// Track the event through the SDK22SFMCSdk.track(removeEvent)
Related Events
AddToCartEvent - E-commerce event for when a user adds an item to their shopping cart
ReplaceCartEvent - E-commerce event for when a user replaces their shopping cart with a list of items
See Also
CartEvent - Parent sealed class for cart-related events