Tracking Events
Track user actions to power automations, segments, and personalization. The SDK auto-tracks page views — use track() for everything else.
Usage
sunrise.push(['track', 'event_name', { /* properties */ }]);Standard Events
These events have special handling in the Postscript platform:
| Event | When to Send | Powers |
|---|---|---|
order.created | After a successful purchase | Revenue attribution, purchase exclusions, post-purchase flows |
checkout.started | When user begins checkout | Abandoned checkout flows |
product.viewed | When user views a product page | Browse abandonment, price drop alerts, low inventory alerts |
cart.item.added | When user adds item to cart | Cart abandonment, low inventory alerts |
order.created
Critical for revenue attribution. The total field is used to calculate attributed revenue. Send this event server-side if possible for accuracy.
sunrise.push(['track', 'order.created', {
order_id: 'order_12345', // required
total: 139.97, // required — used for attribution
subtotal: 129.97,
currency: 'USD',
financial_status: 'paid',
line_items: [
{
product_id: 'prod_abc',
title: 'Classic Cotton Tee',
quantity: 2,
price: 29.99,
sku: 'CCT-BLU-M',
variant_id: 'var_123',
product_type: 'T-Shirts',
vendor: 'Your Brand'
}
]
}]);| Field | Type | Required | Description |
|---|---|---|---|
order_id | string | Yes | Unique order identifier |
total | number | Yes | Total order value (used for attribution) |
subtotal | number | No | Subtotal before tax/shipping |
currency | string | No | ISO 4217 currency code (e.g., USD, EUR) |
financial_status | string | No | paid, pending, refunded, etc. |
line_items | array | No | Array of purchased products |
checkout.started
Track when users begin checkout to power abandoned checkout flows.
sunrise.push(['track', 'checkout.started', {
checkout_id: 'checkout_abc123',
total: 139.97,
subtotal: 129.97,
currency: 'USD',
abandoned_checkout_url: 'https://yourstore.com/checkout/recover/abc123',
line_items: [
{
product_id: 'prod_abc',
title: 'Classic Cotton Tee',
quantity: 2,
price: 29.99
}
]
}]);| Field | Type | Description |
|---|---|---|
checkout_id | string | Unique checkout session identifier |
total | number | Cart/checkout total value |
currency | string | ISO 4217 currency code |
abandoned_checkout_url | string | URL to recover the checkout (for SMS/email links) |
line_items | array | Products in checkout (same format as order) |
product.viewed
Track product page views for browse abandonment, price drop, and low inventory flows.
sunrise.push(['track', 'product.viewed', {
product_id: 'prod_abc', // required
product_name: 'Classic Cotton Tee',
price: 29.99,
currency: 'USD',
variant_id: 'var_123',
category: 'T-Shirts',
brand: 'Your Brand',
url: window.location.href,
image_url: 'https://yourstore.com/images/product.jpg'
}]);cart.item.added
Track when users add items to cart.
sunrise.push(['track', 'cart.item.added', {
product_id: 'prod_abc', // required
variant_id: 'var_123',
product_name: 'Classic Cotton Tee',
quantity: 1,
price: 29.99,
currency: 'USD',
cart_id: 'cart_xyz',
cart_value: 59.98
}]);Custom Events
Track any event relevant to your business:
// Newsletter signup
sunrise.push(['track', 'newsletter.subscribed', {
source: 'footer_form',
interests: ['new_arrivals', 'sales']
}]);
// Wishlist add
sunrise.push(['track', 'wishlist.added', {
product_id: 'prod_abc',
product_name: 'Classic Cotton Tee'
}]);
// Search
sunrise.push(['track', 'search.submitted', {
query: 'blue shirt',
results_count: 24
}]);Custom events can trigger automations and update segment membership just like standard events.