Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Purchase Tracking

Call FireworkSdk.shopping.trackPurchase after your application confirms a completed purchase. This reports analytics; it does not charge the customer, modify the cart, or complete checkout. Initialize the SDK before tracking purchases.

Function Signature

fun trackPurchase(
    orderId: String,
    value: Double? = null,
    currencyCode: String? = null,
    countryCode: String? = null,
    additionalInfo: Map<String, String> = mutableMapOf(),
    products: List<ProductItem>? = null,
    shippingPrice: Double? = null,
    subtotal: Double? = null,
    totalDiscounts: Double? = null,
)

Parameters

Parameter
Type
Required
Meaning / default

orderId

String

Yes

Your order/transaction identifier.

value

Double?

No

Final order value in currency units; null reports 0.0.

currencyCode

String?

No

Currency code, for example USD; defaults to USD.

countryCode

String?

No

Country code, for example US; defaults to the device locale's country when available. Supply it explicitly for the order's market.

additionalInfo

Map<String, String>

No

Additional metadata; defaults to an empty map.

products

List<ProductItem>?

No

Purchased line items; defaults to null.

shippingPrice

Double?

No

Shipping cost; null when unavailable/not applicable.

subtotal

Double?

No

Merchandise subtotal before taxes and discounts; null reports 0.0.

totalDiscounts

Double?

No

Total discount amount; defaults to null. Available since 6.34.1.

Use currency amounts, not integer cents. The SDK reports the values you supply; it does not calculate the final order value from line items, shipping, or discounts. Prefer explicit order totals and currency for meaningful reporting.

ProductItem Structure

Property
Required
Meaning

productId

Yes for the constructor

Commerce product identifier. Used as the tracking SKU when sku is omitted.

price

Yes

Unit price in currency units.

quantity

Yes

Number of units purchased.

productName

No

Human-readable product name; available since 6.34.1.

sku

No

Purchased SKU, typically identifying a variant; takes precedence over productId for tracking. Available since 6.34.1.

SKU-only Products

Since 6.34.1, ProductItem.fromSku supports integrations that only have a SKU:

The factory returns a ProductItem and uses the supplied SKU for its required product identifier. You do not need to look up a separate Firework internal ID.

Usage Examples

Basic Purchase Tracking

Complete Purchase with Products

Minimal Configuration

Only orderId is required by the API:

This omits line items and reports default monetary values. Use the complete example when your checkout provides order details. Call tracking from your confirmed-purchase flow; do not infer a completed purchase from a shopping CTA click.

Last updated

Was this helpful?