Swan SDK
E-commerce

Standard e-commerce events

Which SDK method to call for each of Swan's standard e-commerce events, on every platform, and what to pass to it, with required fields marked.

Swan's segments, journeys and reports are built on a set of standard e-commerce events. Track the shopper actions below with the method and fields shown on this page, and they can be used across Swan straight away. For any other action, see Custom events.

Fields marked * are required.


Before you start

  • Use field names exactly as shown. They are case-sensitive, for example productId, totalAmount and orderId.
  • Send amounts as numbers in the currency's main unit, for example 149.50 for AED 149.50 (not 14950).
  • Use your catalogue product code as productId, the same code as in the product catalogue you share with Swan. Swan uses it to look up the product's name, brand and category, so you don't need to send those.
  • Set the currency once with setCurrency(...), for example setCurrency("AED"). It is added to every event for you. Purchase needs it.
  • Device and session details are added for you, as listed under Sent automatically with every event below.
  • Always send the required fields. An event without them is still recorded, but it can't be used where those fields are needed, for example in a segment that filters on them.

Sent automatically with every event

Besides the fields you pass, every event carries these. You don't pass them to the event methods.

WhatWhere it comes from
Platform (Android, iOS or Web)Read by the SDK
OS versionRead by the SDK
Device model and brandRead by the SDK
Device IDCreated by the SDK on first launch
Session IDCreated by the SDK for each session
CustomerThe signed-in customer, once login(...) or identify(...) has been called; otherwise the anonymous device
CountrySet once with setCountry(...), for example setCountry("AE")
CurrencySet once with setCurrency(...), for example setCurrency("AED")
Business unitSet once with setBusinessUnit(...), if you have more than one

The basket

Checkout started, Purchase, Checkout cancelled and Order shipped include the items in the basket as productIds: a list with one entry per item. Each event lists the fields an item takes, and its example shows a complete basket.

Code examples

React Native examples use the SDK instance:

import SwanSDK from '@loyalytics/swan-react-native-sdk';

const sdk = SwanSDK.getCurrentInstance();

Web examples use the package exports:

import { Swan, SwanEvents } from '@loyalytics/swan-web-sdk';

Standard events you can send

Every standard event you can send with the SDK, and the method to call on each platform.

EventShopper actionMethod (Android / iOS / Web)React Native
App launchedOpens the appSwanEvents.appLaunched (automatic on mobile)sdk.appLaunched
User loginSigns inSwan.loginsdk.login
User logoutSigns outSwan.logoutsdk.logout
App updatedUpdates the appSwanEvents.appUpdatedsdk.appUpdated
ScreenViews a screen or pageSwanEvents.screensdk.screen
SearchSearches the catalogueSwanEvents.searchsdk.search
Product viewedViews a productSwanEvents.productViewedsdk.productViewed
Product clickedClicks a productSwanEvents.productClickedsdk.productClicked
Product added to wishlistAdds to wishlistSwanEvents.productAddedToWishlistsdk.productAddedToWishlist
Product removed from wishlistRemoves from wishlistSwanEvents.productRemovedFromWishlistsdk.productRemovedFromWishlist
Product added to cartAdds to cartSwanEvents.productAddedToAddTocartsdk.productAddedToAddTocart
Product removed from cartRemoves from cartSwanEvents.productRemovedFromAddToCartsdk.productRemovedFromAddToCart
Product quantity selectedChanges a quantitySwanEvents.productQuantitySelectedsdk.productQuantitySelected
Cart clearedEmpties the cartSwanEvents.clearCartsdk.clearCart
Checkout startedStarts checkoutSwanEvents.checkoutStartedsdk.checkoutStarted
PurchaseCompletes checkout and paysSwanEvents.checkoutCompletedsdk.checkoutCompleted
Checkout cancelledAbandons or cancels checkoutSwanEvents.checkoutCanceledsdk.checkoutCanceled
Order shippedTheir order shipsSwanEvents.shippedsdk.shipped

On iOS, Swan methods are called on Swan.shared (for example Swan.shared.login(...)); SwanEvents methods are static, as on the other platforms.

Orders

Record every completed order with checkoutCompleted, as shown under Purchase.


App and account

App launched

The customer opens the app or site.

On Android, iOS and React Native this is recorded automatically when the app opens and each time it returns to the foreground, so there is nothing to call. On Web, call it once when your site loads.

No fields to pass.

// Nothing to call: the SDK records this automatically when the app opens.
// Nothing to call: the SDK records this automatically when the app opens.
// Nothing to call: the SDK records this automatically when the app opens.
SwanEvents.appLaunched();

User login

The customer signs in. Call login(...) when the customer signs in; this records the sign-in, so no separate tracking call is needed. When the app reopens with the customer still signed in, call identify(...) instead, which doesn't record a new sign-in. See Identify users.

No fields to pass.

lifecycleScope.launch {
    Swan.login("user-12345")
}
Task {
    await Swan.shared.login(identifier: "user-12345")
}
await sdk?.login('user-12345');
await Swan.login('user-12345');

User logout

The customer signs out. Call logout() when the customer signs out; this records the sign-out.

No fields to pass.

Swan.logout()
Swan.shared.logout()
await sdk?.logout();
await Swan.logout();

App updated

The app was updated on the customer's device. Call this the first time the app opens after an update.

FieldTypeDescription
appVersion*stringThe app version after the update.
previousVersionstringThe app version before the update.
updateTypestringHow the update was applied.
updateIdstringIdentifier of the update.
SwanEvents.appUpdated(mapOf(
    "appVersion" to "4.2.0",
    "previousVersion" to "4.1.3",  // optional
    "updateType" to "store",  // optional
    "updateId" to "upd-421",  // optional
))
SwanEvents.appUpdated(attributes: [
    "appVersion": "4.2.0",
    "previousVersion": "4.1.3",  // optional
    "updateType": "store",  // optional
    "updateId": "upd-421",  // optional
])
sdk?.appUpdated({
    appVersion: '4.2.0',
    previousVersion: '4.1.3',  // optional
    updateType: 'store',  // optional
    updateId: 'upd-421',  // optional
});
SwanEvents.appUpdated({
    appVersion: '4.2.0',
    previousVersion: '4.1.3',  // optional
    updateType: 'store',  // optional
    updateId: 'upd-421',  // optional
});

Screen

The customer views a screen or page.

FieldTypeDescription
screenName*stringThe screen or page the customer viewed.

On Web, pass the screen name as the first argument, for example SwanEvents.screen('ProductDetail').

SwanEvents.screen(mapOf("screenName" to "ProductDetail"))
SwanEvents.screen(attributes: ["screenName": "ProductDetail"])
sdk?.screen({ screenName: 'ProductDetail' });
SwanEvents.screen('ProductDetail');

Browsing

The customer searches the catalogue.

FieldTypeDescription
searchKeyword*stringThe term the customer searched for.
SwanEvents.search(mapOf("searchKeyword" to "running shoes"))
SwanEvents.search(attributes: ["searchKeyword": "running shoes"])
sdk?.search({ searchKeyword: 'running shoes' });
SwanEvents.search({ searchKeyword: 'running shoes' });

Product viewed

The customer views a product.

FieldTypeDescription
productId*stringThe product viewed.
productUrlstringLink to the product page.
productImageUrlstringURL of the product image.
SwanEvents.productViewed(mapOf(
    "productId" to "SKU-100",
    "productUrl" to "https://shop.example.com/p/sku-100",  // optional
    "productImageUrl" to "https://cdn.example.com/sku-100.jpg",  // optional
))
SwanEvents.productViewed(attributes: [
    "productId": "SKU-100",
    "productUrl": "https://shop.example.com/p/sku-100",  // optional
    "productImageUrl": "https://cdn.example.com/sku-100.jpg",  // optional
])
sdk?.productViewed({
    productId: 'SKU-100',
    productUrl: 'https://shop.example.com/p/sku-100',  // optional
    productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
});
SwanEvents.productViewed({
    productId: 'SKU-100',
    productUrl: 'https://shop.example.com/p/sku-100',  // optional
    productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
});

Product clicked

The customer clicks a product, for example in a list or a banner.

FieldTypeDescription
productId*stringThe product clicked.
productUrlstringLink to the product page.
productImageUrlstringURL of the product image.
SwanEvents.productClicked(mapOf(
    "productId" to "SKU-100",
    "productUrl" to "https://shop.example.com/p/sku-100",  // optional
    "productImageUrl" to "https://cdn.example.com/sku-100.jpg",  // optional
))
SwanEvents.productClicked(attributes: [
    "productId": "SKU-100",
    "productUrl": "https://shop.example.com/p/sku-100",  // optional
    "productImageUrl": "https://cdn.example.com/sku-100.jpg",  // optional
])
sdk?.productClicked({
    productId: 'SKU-100',
    productUrl: 'https://shop.example.com/p/sku-100',  // optional
    productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
});
SwanEvents.productClicked({
    productId: 'SKU-100',
    productUrl: 'https://shop.example.com/p/sku-100',  // optional
    productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
});

Product added to wishlist

The customer adds a product to their wishlist.

FieldTypeDescription
productId*stringThe product added.
productUrlstringLink to the product page.
productImageUrlstringURL of the product image.
SwanEvents.productAddedToWishlist(mapOf(
    "productId" to "SKU-100",
    "productUrl" to "https://shop.example.com/p/sku-100",  // optional
    "productImageUrl" to "https://cdn.example.com/sku-100.jpg",  // optional
))
SwanEvents.productAddedToWishlist(attributes: [
    "productId": "SKU-100",
    "productUrl": "https://shop.example.com/p/sku-100",  // optional
    "productImageUrl": "https://cdn.example.com/sku-100.jpg",  // optional
])
sdk?.productAddedToWishlist({
    productId: 'SKU-100',
    productUrl: 'https://shop.example.com/p/sku-100',  // optional
    productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
});
SwanEvents.productAddedToWishlist({
    productId: 'SKU-100',
    productUrl: 'https://shop.example.com/p/sku-100',  // optional
    productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
});

Product removed from wishlist

The customer removes a product from their wishlist.

FieldTypeDescription
productId*stringThe product removed.
SwanEvents.productRemovedFromWishlist(mapOf("productId" to "SKU-100"))
SwanEvents.productRemovedFromWishlist(attributes: ["productId": "SKU-100"])
sdk?.productRemovedFromWishlist({ productId: 'SKU-100' });
SwanEvents.productRemovedFromWishlist({ productId: 'SKU-100' });

Cart

Product added to cart

The customer adds a product to their cart.

FieldTypeDescription
productId*stringThe product added.
quantitynumberUnits added.
productUrlstringLink to the product page.
productImageUrlstringURL of the product image.
SwanEvents.productAddedToAddTocart(mapOf(
    "productId" to "SKU-100",
    "quantity" to 1,  // optional
    "productUrl" to "https://shop.example.com/p/sku-100",  // optional
    "productImageUrl" to "https://cdn.example.com/sku-100.jpg",  // optional
))
SwanEvents.productAddedToAddTocart(attributes: [
    "productId": "SKU-100",
    "quantity": 1,  // optional
    "productUrl": "https://shop.example.com/p/sku-100",  // optional
    "productImageUrl": "https://cdn.example.com/sku-100.jpg",  // optional
])
sdk?.productAddedToAddTocart({
    productId: 'SKU-100',
    quantity: 1,  // optional
    productUrl: 'https://shop.example.com/p/sku-100',  // optional
    productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
});
SwanEvents.productAddedToAddTocart({
    productId: 'SKU-100',
    quantity: 1,  // optional
    productUrl: 'https://shop.example.com/p/sku-100',  // optional
    productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
});

Product removed from cart

The customer removes a product from their cart.

FieldTypeDescription
productId*stringThe product removed.
quantitynumberUnits removed.
SwanEvents.productRemovedFromAddToCart(mapOf(
    "productId" to "SKU-100",
    "quantity" to 1,  // optional
))
SwanEvents.productRemovedFromAddToCart(attributes: [
    "productId": "SKU-100",
    "quantity": 1,  // optional
])
sdk?.productRemovedFromAddToCart({
    productId: 'SKU-100',
    quantity: 1,  // optional
});
SwanEvents.productRemovedFromAddToCart({
    productId: 'SKU-100',
    quantity: 1,  // optional
});

Product quantity selected

The customer changes the quantity of a product, for example on the product page or in the cart.

FieldTypeDescription
productId*stringThe product.
quantity*numberThe quantity selected.
SwanEvents.productQuantitySelected(mapOf(
    "productId" to "SKU-100",
    "quantity"  to 3,
))
SwanEvents.productQuantitySelected(attributes: [
    "productId": "SKU-100",
    "quantity": 3,
])
sdk?.productQuantitySelected({ productId: 'SKU-100', quantity: 3 });
SwanEvents.productQuantitySelected({ productId: 'SKU-100', quantity: 3 });

Cart cleared

The customer empties their cart.

No fields to pass.

SwanEvents.clearCart()
SwanEvents.clearCart()
sdk?.clearCart();
SwanEvents.clearCart();

Checkout and orders

Checkout started

The customer begins checkout.

FieldTypeDescription
totalAmount*numberThe checkout total after discount, in major units.
productIds*arrayThe basket, one object per line. Lines below.
checkoutIdstringYour identifier for this checkout.
orderIdstringYour order reference, if one exists yet.

Each line in productIds:

FieldTypeDescription
productId*stringThe product on this line.
quantity*numberUnits on this line. Fractions are allowed (1.5 kg).
pricenumberPrice of one unit, not the line total.
skustringYour stock number for the line.
productNamestringThe product name as shown to the shopper.
productUrlstringLink to the product page.
productImageUrlstringURL of the product image.
SwanEvents.checkoutStarted(mapOf(
    "checkoutId" to "co-abc",  // optional
    "orderId" to "ORD-9001",  // optional
    "totalAmount" to 142.45,
    "productIds" to listOf(
        mapOf(
            "productId" to "SKU-100",
            "quantity" to 1,
            "price" to 49.95,  // optional
            "sku" to "STK-100",  // optional
            "productName" to "Trail Runner",  // optional
            "productUrl" to "https://shop.example.com/p/sku-100",  // optional
            "productImageUrl" to "https://cdn.example.com/sku-100.jpg",  // optional
        ),
        mapOf(
            "productId" to "SKU-200",
            "quantity" to 2,
            "price" to 46.25,  // optional
            "sku" to "STK-200",  // optional
            "productName" to "Running Socks",  // optional
            "productUrl" to "https://shop.example.com/p/sku-200",  // optional
            "productImageUrl" to "https://cdn.example.com/sku-200.jpg",  // optional
        ),
    ),
))
SwanEvents.checkoutStarted(attributes: [
    "checkoutId": "co-abc",  // optional
    "orderId": "ORD-9001",  // optional
    "totalAmount": 142.45,
    "productIds": [
        [
            "productId": "SKU-100",
            "quantity": 1,
            "price": 49.95,  // optional
            "sku": "STK-100",  // optional
            "productName": "Trail Runner",  // optional
            "productUrl": "https://shop.example.com/p/sku-100",  // optional
            "productImageUrl": "https://cdn.example.com/sku-100.jpg",  // optional
        ],
        [
            "productId": "SKU-200",
            "quantity": 2,
            "price": 46.25,  // optional
            "sku": "STK-200",  // optional
            "productName": "Running Socks",  // optional
            "productUrl": "https://shop.example.com/p/sku-200",  // optional
            "productImageUrl": "https://cdn.example.com/sku-200.jpg",  // optional
        ],
    ],
])
sdk?.checkoutStarted({
    checkoutId: 'co-abc',  // optional
    orderId: 'ORD-9001',  // optional
    totalAmount: 142.45,
    productIds: [
        {
            productId: 'SKU-100',
            quantity: 1,
            price: 49.95,  // optional
            sku: 'STK-100',  // optional
            productName: 'Trail Runner',  // optional
            productUrl: 'https://shop.example.com/p/sku-100',  // optional
            productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
        },
        {
            productId: 'SKU-200',
            quantity: 2,
            price: 46.25,  // optional
            sku: 'STK-200',  // optional
            productName: 'Running Socks',  // optional
            productUrl: 'https://shop.example.com/p/sku-200',  // optional
            productImageUrl: 'https://cdn.example.com/sku-200.jpg',  // optional
        },
    ],
});
SwanEvents.checkoutStarted({
    checkoutId: 'co-abc',  // optional
    orderId: 'ORD-9001',  // optional
    totalAmount: 142.45,
    productIds: [
        {
            productId: 'SKU-100',
            quantity: 1,
            price: 49.95,  // optional
            sku: 'STK-100',  // optional
            productName: 'Trail Runner',  // optional
            productUrl: 'https://shop.example.com/p/sku-100',  // optional
            productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
        },
        {
            productId: 'SKU-200',
            quantity: 2,
            price: 46.25,  // optional
            sku: 'STK-200',  // optional
            productName: 'Running Socks',  // optional
            productUrl: 'https://shop.example.com/p/sku-200',  // optional
            productImageUrl: 'https://cdn.example.com/sku-200.jpg',  // optional
        },
    ],
});

Purchase

The customer completes checkout and pays. Send it once per order.

FieldTypeDescription
orderId*stringYour order reference.
totalAmount*numberThe order total after discount, in major units.
currency*stringThree-letter ISO 4217 code, for example AED. Set once with setCurrency(...) and added for you.
productIds*arrayThe basket, one object per line. Lines below.
checkoutIdstringThe checkoutId you sent with Checkout started, if any.

Each line in productIds:

FieldTypeDescription
productId*stringThe product on this line.
quantity*numberUnits on this line. Fractions are allowed (1.5 kg).
price*numberPrice of one unit, not the line total.
productNamestringThe product name as shown to the shopper.
productUrlstringLink to the product page.
productImageUrlstringURL of the product image.
Swan.setCurrency("AED") // once, at startup

SwanEvents.checkoutCompleted(mapOf(
    "orderId" to "ORD-9001",
    "checkoutId" to "co-abc",  // optional
    "totalAmount" to 142.45,
    "productIds" to listOf(
        mapOf(
            "productId" to "SKU-100",
            "quantity" to 1,
            "price" to 49.95,
            "productName" to "Trail Runner",  // optional
            "productUrl" to "https://shop.example.com/p/sku-100",  // optional
            "productImageUrl" to "https://cdn.example.com/sku-100.jpg",  // optional
        ),
        mapOf(
            "productId" to "SKU-200",
            "quantity" to 2,
            "price" to 46.25,
            "productName" to "Running Socks",  // optional
            "productUrl" to "https://shop.example.com/p/sku-200",  // optional
            "productImageUrl" to "https://cdn.example.com/sku-200.jpg",  // optional
        ),
    ),
))
Swan.shared.setCurrency("AED") // once, at startup

SwanEvents.checkoutCompleted(attributes: [
    "orderId": "ORD-9001",
    "checkoutId": "co-abc",  // optional
    "totalAmount": 142.45,
    "productIds": [
        [
            "productId": "SKU-100",
            "quantity": 1,
            "price": 49.95,
            "productName": "Trail Runner",  // optional
            "productUrl": "https://shop.example.com/p/sku-100",  // optional
            "productImageUrl": "https://cdn.example.com/sku-100.jpg",  // optional
        ],
        [
            "productId": "SKU-200",
            "quantity": 2,
            "price": 46.25,
            "productName": "Running Socks",  // optional
            "productUrl": "https://shop.example.com/p/sku-200",  // optional
            "productImageUrl": "https://cdn.example.com/sku-200.jpg",  // optional
        ],
    ],
])
sdk?.setCurrency('AED'); // once, at startup

sdk?.checkoutCompleted({
    orderId: 'ORD-9001',
    checkoutId: 'co-abc',  // optional
    totalAmount: 142.45,
    productIds: [
        {
            productId: 'SKU-100',
            quantity: 1,
            price: 49.95,
            productName: 'Trail Runner',  // optional
            productUrl: 'https://shop.example.com/p/sku-100',  // optional
            productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
        },
        {
            productId: 'SKU-200',
            quantity: 2,
            price: 46.25,
            productName: 'Running Socks',  // optional
            productUrl: 'https://shop.example.com/p/sku-200',  // optional
            productImageUrl: 'https://cdn.example.com/sku-200.jpg',  // optional
        },
    ],
});
Swan.setCurrency('AED'); // once, at startup

SwanEvents.checkoutCompleted({
    orderId: 'ORD-9001',
    checkoutId: 'co-abc',  // optional
    totalAmount: 142.45,
    productIds: [
        {
            productId: 'SKU-100',
            quantity: 1,
            price: 49.95,
            productName: 'Trail Runner',  // optional
            productUrl: 'https://shop.example.com/p/sku-100',  // optional
            productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
        },
        {
            productId: 'SKU-200',
            quantity: 2,
            price: 46.25,
            productName: 'Running Socks',  // optional
            productUrl: 'https://shop.example.com/p/sku-200',  // optional
            productImageUrl: 'https://cdn.example.com/sku-200.jpg',  // optional
        },
    ],
});

Checkout cancelled

The customer abandons or cancels checkout. Fields are the same as Checkout started.

FieldTypeDescription
totalAmount*numberThe checkout total after discount, in major units.
productIds*arrayThe basket, one object per line. Lines below.
checkoutIdstringYour identifier for this checkout.
orderIdstringYour order reference, if one exists yet.

Each line in productIds:

FieldTypeDescription
productId*stringThe product on this line.
quantity*numberUnits on this line.
pricenumberPrice of one unit, not the line total.
skustringYour stock number for the line.
productNamestringThe product name as shown to the shopper.
productUrlstringLink to the product page.
productImageUrlstringURL of the product image.
SwanEvents.checkoutCanceled(mapOf(
    "checkoutId" to "co-abc",  // optional
    "orderId" to "ORD-9001",  // optional
    "totalAmount" to 142.45,
    "productIds" to listOf(
        mapOf(
            "productId" to "SKU-100",
            "quantity" to 1,
            "price" to 49.95,  // optional
            "sku" to "STK-100",  // optional
            "productName" to "Trail Runner",  // optional
            "productUrl" to "https://shop.example.com/p/sku-100",  // optional
            "productImageUrl" to "https://cdn.example.com/sku-100.jpg",  // optional
        ),
        mapOf(
            "productId" to "SKU-200",
            "quantity" to 2,
            "price" to 46.25,  // optional
            "sku" to "STK-200",  // optional
            "productName" to "Running Socks",  // optional
            "productUrl" to "https://shop.example.com/p/sku-200",  // optional
            "productImageUrl" to "https://cdn.example.com/sku-200.jpg",  // optional
        ),
    ),
))
SwanEvents.checkoutCanceled(attributes: [
    "checkoutId": "co-abc",  // optional
    "orderId": "ORD-9001",  // optional
    "totalAmount": 142.45,
    "productIds": [
        [
            "productId": "SKU-100",
            "quantity": 1,
            "price": 49.95,  // optional
            "sku": "STK-100",  // optional
            "productName": "Trail Runner",  // optional
            "productUrl": "https://shop.example.com/p/sku-100",  // optional
            "productImageUrl": "https://cdn.example.com/sku-100.jpg",  // optional
        ],
        [
            "productId": "SKU-200",
            "quantity": 2,
            "price": 46.25,  // optional
            "sku": "STK-200",  // optional
            "productName": "Running Socks",  // optional
            "productUrl": "https://shop.example.com/p/sku-200",  // optional
            "productImageUrl": "https://cdn.example.com/sku-200.jpg",  // optional
        ],
    ],
])
sdk?.checkoutCanceled({
    checkoutId: 'co-abc',  // optional
    orderId: 'ORD-9001',  // optional
    totalAmount: 142.45,
    productIds: [
        {
            productId: 'SKU-100',
            quantity: 1,
            price: 49.95,  // optional
            sku: 'STK-100',  // optional
            productName: 'Trail Runner',  // optional
            productUrl: 'https://shop.example.com/p/sku-100',  // optional
            productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
        },
        {
            productId: 'SKU-200',
            quantity: 2,
            price: 46.25,  // optional
            sku: 'STK-200',  // optional
            productName: 'Running Socks',  // optional
            productUrl: 'https://shop.example.com/p/sku-200',  // optional
            productImageUrl: 'https://cdn.example.com/sku-200.jpg',  // optional
        },
    ],
});
SwanEvents.checkoutCanceled({
    checkoutId: 'co-abc',  // optional
    orderId: 'ORD-9001',  // optional
    totalAmount: 142.45,
    productIds: [
        {
            productId: 'SKU-100',
            quantity: 1,
            price: 49.95,  // optional
            sku: 'STK-100',  // optional
            productName: 'Trail Runner',  // optional
            productUrl: 'https://shop.example.com/p/sku-100',  // optional
            productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
        },
        {
            productId: 'SKU-200',
            quantity: 2,
            price: 46.25,  // optional
            sku: 'STK-200',  // optional
            productName: 'Running Socks',  // optional
            productUrl: 'https://shop.example.com/p/sku-200',  // optional
            productImageUrl: 'https://cdn.example.com/sku-200.jpg',  // optional
        },
    ],
});

Order shipped

The customer's order has shipped.

FieldTypeDescription
orderId*stringThe order that shipped.
postalCodestringDelivery postal code.
productIdsarrayThe lines shipped, one object per line. Lines below.

Each line in productIds (all optional):

FieldTypeDescription
productIdstringThe product on this line.
quantitynumberUnits shipped on this line.
pricenumberPrice of one unit, not the line total.
skustringYour stock number for the line.
productNamestringThe product name as shown to the shopper.
productUrlstringLink to the product page.
productImageUrlstringURL of the product image.
SwanEvents.shipped(mapOf(
    "orderId" to "ORD-9001",
    "postalCode" to "00000",  // optional
    "productIds" to listOf(  // optional
        mapOf(
            "productId" to "SKU-100",  // optional
            "quantity" to 1,  // optional
            "price" to 49.95,  // optional
            "sku" to "STK-100",  // optional
            "productName" to "Trail Runner",  // optional
            "productUrl" to "https://shop.example.com/p/sku-100",  // optional
            "productImageUrl" to "https://cdn.example.com/sku-100.jpg",  // optional
        ),
        mapOf(
            "productId" to "SKU-200",  // optional
            "quantity" to 2,  // optional
            "price" to 46.25,  // optional
            "sku" to "STK-200",  // optional
            "productName" to "Running Socks",  // optional
            "productUrl" to "https://shop.example.com/p/sku-200",  // optional
            "productImageUrl" to "https://cdn.example.com/sku-200.jpg",  // optional
        ),
    ),
))
SwanEvents.shipped(attributes: [
    "orderId": "ORD-9001",
    "postalCode": "00000",  // optional
    "productIds": [  // optional
        [
            "productId": "SKU-100",  // optional
            "quantity": 1,  // optional
            "price": 49.95,  // optional
            "sku": "STK-100",  // optional
            "productName": "Trail Runner",  // optional
            "productUrl": "https://shop.example.com/p/sku-100",  // optional
            "productImageUrl": "https://cdn.example.com/sku-100.jpg",  // optional
        ],
        [
            "productId": "SKU-200",  // optional
            "quantity": 2,  // optional
            "price": 46.25,  // optional
            "sku": "STK-200",  // optional
            "productName": "Running Socks",  // optional
            "productUrl": "https://shop.example.com/p/sku-200",  // optional
            "productImageUrl": "https://cdn.example.com/sku-200.jpg",  // optional
        ],
    ],
])
sdk?.shipped({
    orderId: 'ORD-9001',
    postalCode: '00000',  // optional
    productIds: [  // optional
        {
            productId: 'SKU-100',  // optional
            quantity: 1,  // optional
            price: 49.95,  // optional
            sku: 'STK-100',  // optional
            productName: 'Trail Runner',  // optional
            productUrl: 'https://shop.example.com/p/sku-100',  // optional
            productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
        },
        {
            productId: 'SKU-200',  // optional
            quantity: 2,  // optional
            price: 46.25,  // optional
            sku: 'STK-200',  // optional
            productName: 'Running Socks',  // optional
            productUrl: 'https://shop.example.com/p/sku-200',  // optional
            productImageUrl: 'https://cdn.example.com/sku-200.jpg',  // optional
        },
    ],
});
SwanEvents.shipped({
    orderId: 'ORD-9001',
    postalCode: '00000',  // optional
    productIds: [  // optional
        {
            productId: 'SKU-100',  // optional
            quantity: 1,  // optional
            price: 49.95,  // optional
            sku: 'STK-100',  // optional
            productName: 'Trail Runner',  // optional
            productUrl: 'https://shop.example.com/p/sku-100',  // optional
            productImageUrl: 'https://cdn.example.com/sku-100.jpg',  // optional
        },
        {
            productId: 'SKU-200',  // optional
            quantity: 2,  // optional
            price: 46.25,  // optional
            sku: 'STK-200',  // optional
            productName: 'Running Socks',  // optional
            productUrl: 'https://shop.example.com/p/sku-200',  // optional
            productImageUrl: 'https://cdn.example.com/sku-200.jpg',  // optional
        },
    ],
});

Reference

On this page