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,totalAmountandorderId. - Send amounts as numbers in the currency's main unit, for example
149.50for AED 149.50 (not14950). - 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 examplesetCurrency("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.
| What | Where it comes from |
|---|---|
| Platform (Android, iOS or Web) | Read by the SDK |
| OS version | Read by the SDK |
| Device model and brand | Read by the SDK |
| Device ID | Created by the SDK on first launch |
| Session ID | Created by the SDK for each session |
| Customer | The signed-in customer, once login(...) or identify(...) has been called; otherwise the anonymous device |
| Country | Set once with setCountry(...), for example setCountry("AE") |
| Currency | Set once with setCurrency(...), for example setCurrency("AED") |
| Business unit | Set 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.
| Event | Shopper action | Method (Android / iOS / Web) | React Native |
|---|---|---|---|
| App launched | Opens the app | SwanEvents.appLaunched (automatic on mobile) | sdk.appLaunched |
| User login | Signs in | Swan.login | sdk.login |
| User logout | Signs out | Swan.logout | sdk.logout |
| App updated | Updates the app | SwanEvents.appUpdated | sdk.appUpdated |
| Screen | Views a screen or page | SwanEvents.screen | sdk.screen |
| Search | Searches the catalogue | SwanEvents.search | sdk.search |
| Product viewed | Views a product | SwanEvents.productViewed | sdk.productViewed |
| Product clicked | Clicks a product | SwanEvents.productClicked | sdk.productClicked |
| Product added to wishlist | Adds to wishlist | SwanEvents.productAddedToWishlist | sdk.productAddedToWishlist |
| Product removed from wishlist | Removes from wishlist | SwanEvents.productRemovedFromWishlist | sdk.productRemovedFromWishlist |
| Product added to cart | Adds to cart | SwanEvents.productAddedToAddTocart | sdk.productAddedToAddTocart |
| Product removed from cart | Removes from cart | SwanEvents.productRemovedFromAddToCart | sdk.productRemovedFromAddToCart |
| Product quantity selected | Changes a quantity | SwanEvents.productQuantitySelected | sdk.productQuantitySelected |
| Cart cleared | Empties the cart | SwanEvents.clearCart | sdk.clearCart |
| Checkout started | Starts checkout | SwanEvents.checkoutStarted | sdk.checkoutStarted |
| Purchase | Completes checkout and pays | SwanEvents.checkoutCompleted | sdk.checkoutCompleted |
| Checkout cancelled | Abandons or cancels checkout | SwanEvents.checkoutCanceled | sdk.checkoutCanceled |
| Order shipped | Their order ships | SwanEvents.shipped | sdk.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.
| Field | Type | Description |
|---|---|---|
appVersion* | string | The app version after the update. |
previousVersion | string | The app version before the update. |
updateType | string | How the update was applied. |
updateId | string | Identifier 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.
| Field | Type | Description |
|---|---|---|
screenName* | string | The 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
Search
The customer searches the catalogue.
| Field | Type | Description |
|---|---|---|
searchKeyword* | string | The 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.
| Field | Type | Description |
|---|---|---|
productId* | string | The product viewed. |
productUrl | string | Link to the product page. |
productImageUrl | string | URL 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.
| Field | Type | Description |
|---|---|---|
productId* | string | The product clicked. |
productUrl | string | Link to the product page. |
productImageUrl | string | URL 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.
| Field | Type | Description |
|---|---|---|
productId* | string | The product added. |
productUrl | string | Link to the product page. |
productImageUrl | string | URL 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.
| Field | Type | Description |
|---|---|---|
productId* | string | The 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.
| Field | Type | Description |
|---|---|---|
productId* | string | The product added. |
quantity | number | Units added. |
productUrl | string | Link to the product page. |
productImageUrl | string | URL 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.
| Field | Type | Description |
|---|---|---|
productId* | string | The product removed. |
quantity | number | Units 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.
| Field | Type | Description |
|---|---|---|
productId* | string | The product. |
quantity* | number | The 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.
| Field | Type | Description |
|---|---|---|
totalAmount* | number | The checkout total after discount, in major units. |
productIds* | array | The basket, one object per line. Lines below. |
checkoutId | string | Your identifier for this checkout. |
orderId | string | Your order reference, if one exists yet. |
Each line in productIds:
| Field | Type | Description |
|---|---|---|
productId* | string | The product on this line. |
quantity* | number | Units on this line. Fractions are allowed (1.5 kg). |
price | number | Price of one unit, not the line total. |
sku | string | Your stock number for the line. |
productName | string | The product name as shown to the shopper. |
productUrl | string | Link to the product page. |
productImageUrl | string | URL 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.
| Field | Type | Description |
|---|---|---|
orderId* | string | Your order reference. |
totalAmount* | number | The order total after discount, in major units. |
currency* | string | Three-letter ISO 4217 code, for example AED. Set once with setCurrency(...) and added for you. |
productIds* | array | The basket, one object per line. Lines below. |
checkoutId | string | The checkoutId you sent with Checkout started, if any. |
Each line in productIds:
| Field | Type | Description |
|---|---|---|
productId* | string | The product on this line. |
quantity* | number | Units on this line. Fractions are allowed (1.5 kg). |
price* | number | Price of one unit, not the line total. |
productName | string | The product name as shown to the shopper. |
productUrl | string | Link to the product page. |
productImageUrl | string | URL 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.
| Field | Type | Description |
|---|---|---|
totalAmount* | number | The checkout total after discount, in major units. |
productIds* | array | The basket, one object per line. Lines below. |
checkoutId | string | Your identifier for this checkout. |
orderId | string | Your order reference, if one exists yet. |
Each line in productIds:
| Field | Type | Description |
|---|---|---|
productId* | string | The product on this line. |
quantity* | number | Units on this line. |
price | number | Price of one unit, not the line total. |
sku | string | Your stock number for the line. |
productName | string | The product name as shown to the shopper. |
productUrl | string | Link to the product page. |
productImageUrl | string | URL 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.
| Field | Type | Description |
|---|---|---|
orderId* | string | The order that shipped. |
postalCode | string | Delivery postal code. |
productIds | array | The lines shipped, one object per line. Lines below. |
Each line in productIds (all optional):
| Field | Type | Description |
|---|---|---|
productId | string | The product on this line. |
quantity | number | Units shipped on this line. |
price | number | Price of one unit, not the line total. |
sku | string | Your stock number for the line. |
productName | string | The product name as shown to the shopper. |
productUrl | string | Link to the product page. |
productImageUrl | string | URL 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
- Custom events — track any other action as your own event
- Identify users —
login,identifyandlogout - Concepts → Event model — sessions and how events are sent