Capture Engagement Data (Version 2.x)

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.

Prerequisites 

Before engagement data can be sent to Data 360:

  • The Data 360 Module for the Engagement Mobile SDK must be configured and initialized.
  • Consent to track engagement data must be granted.

Supported Event Types 

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 

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.

  • Cart Event: Track shopping cart interactions
  • Catalog Event: Monitor product catalog engagement
  • Order Event: Capture purchase and order data

Unstructured 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.

Implementation Examples 

iOS
1import SFMCSDK
2import Cdp
3
4...
5
6// collecting the structured AddToCartEvent
7SFMCSdk.track(AddToCartEvent(
8    lineItem: LineItem(
9        catalogObjectType: "Product",
10        catalogObjectId: "product-1",
11        quantity: 1,
12        price: 20.0,
13        currency: "USD",
14        // attributes can contain any custom field data
15        // as long as the schema is modified to define them
16        attributes: [
17            "gift_wrap": false
18        ]
19    )
20))
21
22// collecting an unstructured CustomEvent
23SFMCSdk.track(CustomEvent(
24    name: "CartAbandonment",
25    attributes: [
26        "sku": "COFFEE-NTR-06",
27        "price": 19.99
28    ]
29))

Android 

Android
1import com.salesforce.marketingcloud.sfmcsdk.components.events.CartEvent
2import com.salesforce.marketingcloud.sfmcsdk.components.events.EventManager
3import com.salesforce.marketingcloud.sfmcsdk.SFMCSdk
4
5...
6
7// collecting the structured AddToCartEvent
8SFMCSdk.track(CartEvent.add(
9    lineItem = LineItem(
10        catalogObjectId = "product-1",
11        catalogObjectType = "Product",
12        quantity = 1,
13        price = 20.0,
14        currency = "USD",
15        // attributes can contain any custom field data
16        // as long as the schema is modified to define them
17        attributes = mapOf(
18            "gift_wrap" to false
19        )
20    )
21))
22
23// collecting an unstructured CustomEvent
24SFMCSdk.track(EventManager.customEvent(
25    "CartAbandonment",
26    mapOf(
27        "sku" to "COFFEE-NTR-06",
28        "price" to 19.99
29    )
30))