Version 3.x
Version 2.x
Capture Behavior Data
Post Data from an Authenticated Server-to-Server Connection
Post Data from an Unauthenticated Server-to-Server Connection
The Data 360 Module for the Engagement Mobile SDK enables the collection of rich engagement data from customer interactions within your mobile application through event tracking.
Before engagement data can be sent to Data 360:
SFMCSdk.track(event:) calls are silently dropped (not queued) when consent is optOut or when the event type is blocked during pending. Set consent before or immediately after SDK initialization.
Note
The Engagement Mobile SDK supports two types of events — structured and unstructured events. Both event types are collected using the SFMCSdk.track(event) function.
Structured events have predefined schemas with strict data requirements. They come pre-configured with the Mobile Connector schema for Data 360 and can be extended to capture additional custom data. The Data 360 Module supports the following structured events.
Unstructured events have no predefined data requirements. You must create and add custom event definitions to the Mobile Connector schema for Data 360 ingestion.
1import Cdp
2import SFMCSDK
3
4...
5
6// Add to cart
7SFMCSdk.track(event: AddToCartEvent(
8 lineItem: LineItem(
9 catalogObjectType: "Product",
10 catalogObjectId: "product-001",
11 quantity: 1,
12 price: 29.99,
13 currency: "USD"
14 )
15))
16
17// Purchase order
18SFMCSdk.track(event: PurchaseOrderEvent(
19 order: Order(
20 id: "order-001",
21 lineItems: [
22 LineItem(catalogObjectType: "Product", catalogObjectId: "product-001", quantity: 1)
23 ],
24 totalValue: 29.99,
25 currency: "USD"
26 )
27))
28
29// View catalog object
30SFMCSdk.track(event: ViewCatalogObjectEvent(
31 catalogObject: CatalogObject(
32 type: "Product",
33 id: "product-001",
34 attributes: ["promoCode": "WINTER2025"],
35 relatedCatalogObjects: [
36 "sizes": ["S", "M", "L"]
37 ]
38 )
39))
40
41// Custom event
42if let event = CustomEvent(
43 name: "myCustomEvent",
44 attributes: [
45 "giftWrap": true,
46 "giftMessage": "Happy Birthday"
47 ]
48) {
49 SFMCSdk.track(event: event)
50}CustomEvent(name:attributes:) returns an optional — the call returns nil if the name is empty or contains invalid characters.
Note
On Android, the preferred pattern is calling .track() directly on the event object. This makes null-safety explicit at the call site (event construction can return null on invalid input). The older SFMCSdk.track(CartEvent.add(...)) form still works — both patterns route through the same event bus.
1import com.salesforce.marketingcloud.sfmcsdk.components.events.CartEvent
2import com.salesforce.marketingcloud.sfmcsdk.components.events.EventManager
3
4...
5
6// Add to cart
7CartEvent.add(LineItem(
8 catalogObjectId = "SKU-123",
9 catalogObjectType = "Product",
10 quantity = 1,
11 price = 9.99,
12 currency = "USD"
13))?.track()
14
15// View catalog object
16CatalogEvent.view(CatalogObject(
17 id = "SKU-123",
18 type = "Product"
19))?.track()
20
21// Purchase order
22OrderEvent.purchase(Order(
23 id = "order-1",
24 totalValue = 29.99,
25 currency = "USD",
26 lineItems = listOf(
27 LineItem(
28 catalogObjectId = "SKU-123",
29 catalogObjectType = "Product",
30 quantity = 1,
31 price = 29.99,
32 currency = "USD"
33 )
34 )
35))?.track()
36
37// Custom event (via sfmcsdk event bus — recommended)
38EventManager.customEvent(
39 name = "level_complete",
40 attributes = mapOf("level" to 5)
41)?.track()