Track Conversion

To track a purchase made through your mobile app, use the trackCartConversion method.

For more information about using this method with Einstein Recommendations, see Salesforce Help: Track Purchase Details.

For SDK version 10 and later, use this example.

1MarketingCloudSdk.requestSdk { mc in
2  let cartItem = mc?.cartItemDictionary(
3    price:  1.10,
4    quantity: 1,
5    item: "123456",
6    uniqueId: "uniqueId_123456"
7  )
8  let cart = mc?.cartDictionary(cartItem: [cartItem])
9  let order = mc?.orderDictionary(
10    orderNumber: "123456",
11    shipping: 2.11,
12    discount: 4.99,
13    cart: cart!
14  )
15  mc?.trackCartConversion(order!)
16}

For SDK version 8, use this example.

1SFMCSdk.requestPushSdk { mp in
2  let cartItem = mp.cartItemDictionary(
3    price:  1.10,
4    quantity: 1,
5    item: "123456",
6    uniqueId: "uniqueId_123456"
7  )
8  let cart = mp.cartDictionary(cartItem: [cartItem])
9  let order = mp.orderDictionary(
10    orderNumber: "123456",
11    shipping: 2.11,
12    discount: 4.99,
13    cart: cart!
14  )
15  mp.trackCartConversion(order!)
16}

For SDK version 7, use this example.

1let cartItem = MarketingCloudSDK.sharedInstance().sfmc_cartItemDictionary(
2  withPrice: 1.10,
3  quantity: 1,
4  item: "123456",
5  uniqueId: "uniqueId_123456"
6)
7let cart = MarketingCloudSDK.sharedInstance().sfmc_cartDictionary(
8  withCartItemDictionaryArray: [cartItem!]
9)
10let order = MarketingCloudSDK.sharedInstance().sfmc_orderDictionary(
11  withOrderNumber: "123456", shipping: 2.11, discount: 4.99, cart: cart!
12)
13MarketingCloudSDK.sharedInstance().sfmc_trackCartConversion(order!)