E-Commerce Tracking
The Joryio SDKs include built-in e-commerce tracking for product engagement, cart activity, and purchase transactions. The tracker works the same way across every platform: the same methods, the same standard event names, and the same property semantics - only the language syntax differs.
Pick your platform in any code example below; the choice syncs across the whole page. For installation and configuration, see the platform guides: Web SDK, iOS SDK, Android SDK, React Native SDK. React Native has no dedicated tracker - its tab shows the equivalent Joryio.track() calls (see React Native below).
ID Naming Convention
Joryio uses a clear naming convention for identifiers:
| Your ID | Description | Example |
|---|---|---|
productId | Your product identifier (SKU, product ID from your e-commerce platform) | "SKU-12345" |
orderId | Your order identifier (order number from your platform) | "ORD-2024-001" |
userId | Your user identifier (passed to identify()) | "user-123" |
Use your own identifiers naturally - no special prefixes needed.
Initialize the E-Commerce Tracker
- Web (JS)
- iOS (Swift)
- Android (Kotlin)
- React Native
// Get the e-commerce tracker from your SDK instance
// (joryio is the instance created with `new JoryioSDK({ sdkKey: ... })`)
const ecommerce = joryio.ecommerce({
currency: 'USD' // Default currency for all events
});
// Get the e-commerce tracker with default currency
let ecommerce = Joryio.shared.ecommerce(config: EcommerceConfig(currency: "USD"))
import io.joryio.sdk.ecommerce.*
// Get the e-commerce tracker with default currency
val ecommerce = Joryio.getInstance().ecommerce(EcommerceConfig(currency = "USD"))
// The React Native SDK has no dedicated e-commerce tracker and no
// tracker-level currency config. Send the same standard events with
// Joryio.track(), and include `currency` as a property on each
// monetary event instead.
import Joryio from '@joryio/react-native-sdk';
Track Product Views & Search
- Web (JS)
- iOS (Swift)
- Android (Kotlin)
- React Native
// When user views a product page
ecommerce.viewProduct({
productId: 'SKU-12345',
name: 'Classic Blue T-Shirt',
price: 29.99,
category: 'Clothing/T-Shirts',
brand: 'Acme Apparel',
imageUrl: 'https://example.com/images/blue-tshirt.jpg',
url: 'https://example.com/products/blue-tshirt'
});
// When user views a category page
ecommerce.viewCategory('tshirts', 'T-Shirts');
// When user searches
ecommerce.search('blue shirts', 42); // query, result count
// Track product view
let product = EcommerceProduct(
productId: "SKU-12345",
name: "Classic Blue T-Shirt",
price: 29.99,
category: "Clothing",
brand: "Acme Apparel",
variant: "Size M",
sku: "BTS-001-M"
)
ecommerce.viewProduct(product)
// Track category view
ecommerce.viewCategory(categoryId: "cat_123", categoryName: "T-Shirts", properties: [
"sort_by": "popularity"
])
// Track product search
ecommerce.search(query: "blue shirts", resultCount: 42)
// Track product view
val product = EcommerceProduct(
productId = "SKU-12345",
name = "Classic Blue T-Shirt",
price = 29.99,
category = "Clothing",
brand = "Acme Apparel",
variant = "Size M",
sku = "BTS-001-M"
)
ecommerce.viewProduct(product)
// Track category view
ecommerce.viewCategory(
categoryId = "cat_123",
categoryName = "T-Shirts",
properties = mapOf("sort_by" to "popularity")
)
// Track product search
ecommerce.search(query = "blue shirts", resultCount = 42)
// When user views a product page
Joryio.track('Product Viewed', {
product_id: 'SKU-12345',
name: 'Classic Blue T-Shirt',
price: 29.99,
category: 'Clothing/T-Shirts',
brand: 'Acme Apparel',
image_url: 'https://example.com/images/blue-tshirt.jpg',
url: 'https://example.com/products/blue-tshirt',
currency: 'USD',
});
// When user views a category page
Joryio.track('Product List Viewed', {
category_id: 'tshirts',
category_name: 'T-Shirts',
});
// When user searches
Joryio.track('Products Searched', {
query: 'blue shirts',
result_count: 42,
});
Track Cart Activity
- Web (JS)
- iOS (Swift)
- Android (Kotlin)
- React Native
// Add item to cart
ecommerce.addToCart({
productId: 'SKU-12345',
name: 'Classic Blue T-Shirt',
price: 29.99,
quantity: 1,
variantId: 'var-medium',
sku: 'BTS-001-M'
}, 59.98); // Optional: current cart value
// Remove item from cart
ecommerce.removeFromCart({
productId: 'SKU-12345',
name: 'Classic Blue T-Shirt',
price: 29.99
}, 1); // quantity to remove
// Update entire cart
ecommerce.updateCart([
{ productId: 'SKU-12345', name: 'Blue T-Shirt', price: 29.99, quantity: 2 },
{ productId: 'SKU-67890', name: 'Black Jeans', price: 49.99, quantity: 1 }
], 109.97); // items array, total cart value
// Add item to cart
let cartItem = EcommerceCartItem(
productId: "SKU-12345",
name: "Classic Blue T-Shirt",
price: 29.99,
quantity: 2,
category: "Clothing"
)
ecommerce.addToCart(item: cartItem, cartValue: 59.98)
// Remove from cart
ecommerce.removeFromCart(product: product, quantity: 1)
// Update cart
ecommerce.updateCart(items: [cartItem1, cartItem2], cartValue: 89.97)
// Add item to cart
val cartItem = EcommerceCartItem(
productId = "SKU-12345",
name = "Classic Blue T-Shirt",
price = 29.99,
quantity = 2,
category = "Clothing"
)
ecommerce.addToCart(item = cartItem, cartValue = 59.98)
// Remove from cart
ecommerce.removeFromCart(product = product, quantity = 1)
// Update cart
ecommerce.updateCart(items = listOf(cartItem1, cartItem2), cartValue = 89.97)
// Add item to cart
Joryio.track('Product Added', {
product_id: 'SKU-12345',
name: 'Classic Blue T-Shirt',
price: 29.99,
quantity: 1,
variant_id: 'var-medium',
sku: 'BTS-001-M',
item_total: 29.99, // price * quantity
cart_value: 59.98,
currency: 'USD',
});
// Remove item from cart
Joryio.track('Product Removed', {
product_id: 'SKU-12345',
name: 'Classic Blue T-Shirt',
price: 29.99,
quantity: 1,
currency: 'USD',
});
// Update entire cart
Joryio.track('Cart Updated', {
items: [
{ product_id: 'SKU-12345', name: 'Blue T-Shirt', price: 29.99, quantity: 2 },
{ product_id: 'SKU-67890', name: 'Black Jeans', price: 49.99, quantity: 1 },
],
item_count: 3,
cart_value: 109.97,
currency: 'USD',
});
Track Checkout Flow
- Web (JS)
- iOS (Swift)
- Android (Kotlin)
- React Native
// When user starts checkout
ecommerce.startCheckout([
{ productId: 'SKU-12345', name: 'Blue T-Shirt', price: 29.99, quantity: 2 },
{ productId: 'SKU-67890', name: 'Black Jeans', price: 49.99, quantity: 1 }
], 109.97); // items, cart value
// When user adds payment info
ecommerce.addPaymentInfo('credit_card');
// Start checkout
ecommerce.startCheckout(items: cartItems, cartValue: 59.98)
// Add payment info
ecommerce.addPaymentInfo(paymentMethod: "credit_card", properties: [
"card_type": "visa"
])
// Start checkout
ecommerce.startCheckout(items = cartItems, cartValue = 59.98)
// Add payment info
ecommerce.addPaymentInfo(paymentMethod = "credit_card", properties = mapOf(
"card_type" to "visa"
))
// When user starts checkout
Joryio.track('Checkout Started', {
items: [
{ product_id: 'SKU-12345', name: 'Blue T-Shirt', price: 29.99, quantity: 2 },
{ product_id: 'SKU-67890', name: 'Black Jeans', price: 49.99, quantity: 1 },
],
item_count: 3,
value: 109.97,
currency: 'USD',
});
// When user adds payment info
Joryio.track('Payment Info Entered', {
payment_method: 'credit_card',
});
Track Purchases
- Web (JS)
- iOS (Swift)
- Android (Kotlin)
- React Native
// When order is completed
ecommerce.purchase({
orderId: 'ORD-2024-001',
items: [
{
productId: 'SKU-12345',
name: 'Classic Blue T-Shirt',
price: 29.99,
quantity: 2,
category: 'Clothing',
brand: 'Acme'
},
{
productId: 'SKU-67890',
name: 'Black Jeans',
price: 49.99,
quantity: 1
}
],
value: 109.97,
currency: 'USD',
shipping: 5.99,
tax: 8.80,
discount: 10.00,
coupon: 'SAVE10'
});
// Complete purchase
let order = EcommerceOrder(
orderId: "ORD-2024-001",
items: cartItems,
value: 59.98,
currency: "USD",
shipping: 5.99,
tax: 4.80,
discount: 10.00,
coupon: "SAVE10"
)
ecommerce.purchase(order: order)
// Complete purchase
val order = EcommerceOrder(
orderId = "ORD-2024-001",
items = cartItems,
value = 59.98,
currency = "USD",
shipping = 5.99,
tax = 4.80,
discount = 10.00,
coupon = "SAVE10"
)
ecommerce.purchase(order)
// When order is completed
Joryio.track('Order Completed', {
order_id: 'ORD-2024-001',
items: [
{
product_id: 'SKU-12345',
name: 'Classic Blue T-Shirt',
price: 29.99,
quantity: 2,
category: 'Clothing',
brand: 'Acme',
},
{
product_id: 'SKU-67890',
name: 'Black Jeans',
price: 49.99,
quantity: 1,
},
],
item_count: 3,
value: 109.97,
currency: 'USD',
shipping: 5.99,
tax: 8.80,
discount: 10.00,
coupon: 'SAVE10',
});
The purchase() method requires you to pass the order items explicitly. The SDK does not store cart state client-side and does not pull items from the tracked cart or the server automatically. This ensures accuracy, since the order confirmation page or screen knows the exact items that were purchased.
Track Order Status Changes
- Web (JS)
- iOS (Swift)
- Android (Kotlin)
- React Native
// Order shipped
ecommerce.orderFulfilled('ORD-2024-001', '1Z999AA10123456784', 'UPS');
// Order delivered
ecommerce.orderDelivered('ORD-2024-001');
// Order cancelled
ecommerce.orderCancelled('ORD-2024-001', 'Customer requested');
// Order refunded
ecommerce.orderRefunded('ORD-2024-001', 29.99, 'Product defective');
// Order fulfilled (shipped)
ecommerce.orderFulfilled(orderId: "ORD-2024-001", trackingNumber: "1Z999AA10123456784", carrier: "UPS")
// Order delivered
ecommerce.orderDelivered(orderId: "ORD-2024-001")
// Order cancelled
ecommerce.orderCancelled(orderId: "ORD-2024-001", reason: "Customer requested cancellation")
// Order refunded
ecommerce.orderRefunded(orderId: "ORD-2024-001", refundAmount: 29.99, reason: "Product defective")
// Order fulfilled (shipped)
ecommerce.orderFulfilled(orderId = "ORD-2024-001", trackingNumber = "1Z999AA10123456784", carrier = "UPS")
// Order delivered
ecommerce.orderDelivered(orderId = "ORD-2024-001")
// Order cancelled
ecommerce.orderCancelled(orderId = "ORD-2024-001", reason = "Customer requested cancellation")
// Order refunded
ecommerce.orderRefunded(orderId = "ORD-2024-001", refundAmount = 29.99, reason = "Product defective")
// Order shipped
Joryio.track('Order Fulfilled', {
order_id: 'ORD-2024-001',
tracking_number: '1Z999AA10123456784',
carrier: 'UPS',
});
// Order delivered
Joryio.track('Order Delivered', { order_id: 'ORD-2024-001' });
// Order cancelled
Joryio.track('Order Cancelled', {
order_id: 'ORD-2024-001',
reason: 'Customer requested',
});
// Order refunded
Joryio.track('Order Refunded', {
order_id: 'ORD-2024-001',
refund_amount: 29.99,
reason: 'Product defective',
});
Track Wishlist & Sharing
- Web (JS)
- iOS (Swift)
- Android (Kotlin)
- React Native
// Add to wishlist
ecommerce.addToWishlist({
productId: 'SKU-12345',
name: 'Classic Blue T-Shirt',
price: 29.99
});
// Share product
ecommerce.shareProduct({
productId: 'SKU-12345',
name: 'Classic Blue T-Shirt'
}, 'facebook'); // share method
// Wishlist
ecommerce.addToWishlist(product: product)
ecommerce.removeFromWishlist(product: product)
// Share product
ecommerce.shareProduct(product: product, shareMethod: "twitter")
// Wishlist
ecommerce.addToWishlist(product)
ecommerce.removeFromWishlist(product)
// Share product
ecommerce.shareProduct(product, shareMethod = "twitter")
// Add to wishlist
Joryio.track('Product Added to Wishlist', {
product_id: 'SKU-12345',
name: 'Classic Blue T-Shirt',
price: 29.99,
currency: 'USD',
});
// Remove from wishlist
Joryio.track('Product Removed from Wishlist', {
product_id: 'SKU-12345',
name: 'Classic Blue T-Shirt',
});
// Share product
Joryio.track('Product Shared', {
product_id: 'SKU-12345',
name: 'Classic Blue T-Shirt',
share_method: 'facebook',
});
Track Coupons
- Web (JS)
- iOS (Swift)
- Android (Kotlin)
- React Native
// Coupon applied
ecommerce.applyCoupon('SAVE10', 10.00, 'percentage');
// Coupon removed
ecommerce.removeCoupon('SAVE10');
// Coupon
ecommerce.applyCoupon(couponCode: "SAVE10", discountAmount: 10.00, discountType: "percentage")
ecommerce.removeCoupon(couponCode: "SAVE10")
// Coupon
ecommerce.applyCoupon(couponCode = "SAVE10", discountAmount = 10.00, discountType = "percentage")
ecommerce.removeCoupon(couponCode = "SAVE10")
// Coupon applied
Joryio.track('Coupon Applied', {
coupon_code: 'SAVE10',
discount_amount: 10.00,
discount_type: 'percentage',
});
// Coupon removed
Joryio.track('Coupon Removed', { coupon_code: 'SAVE10' });
Track Reviews
- Web (JS)
- iOS (Swift)
- Android (Kotlin)
- React Native
// Product review submitted
ecommerce.submitReview('SKU-12345', 5, 'Great quality shirt!');
// Review
ecommerce.submitReview(productId: "SKU-12345", rating: 5, reviewText: "Great product!")
// Review
ecommerce.submitReview(productId = "SKU-12345", rating = 5, reviewText = "Great product!")
// Product review submitted
Joryio.track('Product Reviewed', {
product_id: 'SKU-12345',
rating: 5,
review_text: 'Great quality shirt!',
});
Standard E-Commerce Events
The e-commerce tracker sends the same standard events on every platform:
| Event Name | Description |
|---|---|
Product Viewed | User views a product page |
Product List Viewed | User views a category page |
Products Searched | User searches for products |
Product Added | Item added to cart |
Product Removed | Item removed from cart |
Cart Updated | Cart contents changed |
Checkout Started | User begins checkout |
Payment Info Entered | User adds payment method |
Order Completed | Order completed |
Order Fulfilled | Order shipped |
Order Delivered | Order delivered |
Order Cancelled | Order cancelled |
Order Refunded | Order refunded |
Product Added to Wishlist | Product added to wishlist |
Product Removed from Wishlist | Product removed from wishlist |
Product Shared | Product shared |
Coupon Applied | Coupon code applied |
Coupon Removed | Coupon code removed |
Product Reviewed | Product review submitted |
React Native
The React Native SDK does not include a dedicated e-commerce tracker. React Native apps send the exact same standard events with Joryio.track(), using the same event names and the same wire property names the other SDKs' trackers emit (the trackers convert their camelCase inputs to snake_case event properties on the wire). The React Native tab in each section above shows the equivalent Joryio.track() call for every tracker method.
Next Steps
- Web SDK - Installation, configuration, and full API reference
- iOS SDK - Integrate the iOS SDK
- Android SDK - Integrate the Android SDK
- React Native SDK - Integrate the React Native SDK
- Custom Events - Track custom events
- E-Commerce API - Server-side e-commerce integration