PostscriptPostscript Developers
Guides

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:

EventWhen to SendPowers
order.createdAfter a successful purchaseRevenue attribution, purchase exclusions, post-purchase flows
checkout.startedWhen user begins checkoutAbandoned checkout flows
product.viewedWhen user views a product pageBrowse abandonment, price drop alerts, low inventory alerts
cart.item.addedWhen user adds item to cartCart 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'
    }
  ]
}]);
FieldTypeRequiredDescription
order_idstringYesUnique order identifier
totalnumberYesTotal order value (used for attribution)
subtotalnumberNoSubtotal before tax/shipping
currencystringNoISO 4217 currency code (e.g., USD, EUR)
financial_statusstringNopaid, pending, refunded, etc.
line_itemsarrayNoArray 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
    }
  ]
}]);
FieldTypeDescription
checkout_idstringUnique checkout session identifier
totalnumberCart/checkout total value
currencystringISO 4217 currency code
abandoned_checkout_urlstringURL to recover the checkout (for SMS/email links)
line_itemsarrayProducts 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.