TrackBee DocsTrackBee Docs
Tracking SDKEvents

checkout_completed

An order was placed. The event that carries your revenue.

Send this on the order confirmation, once per order.

trackbee.track('checkout_completed', {
  order_id: 5512049,
  subtotal_price: '74.48',
  total_price: '68.49',
  discount_amount: '5.99',
  is_first_order: true,
  currency: 'EUR',
  email: 'sam@example.com',
  phone: '+31612345678',
  first_name: 'Sam',
  last_name: 'de Vries',
  address1: 'Oudegracht 12',
  address2: 'Apt 3',
  city: 'Utrecht',
  country_code: 'NL',
  line_items: [
    {
      product_id: '8472019',
      variant_id: '4410228',
      price: '29.99',
      quantity: 2,
      currency: 'EUR',
      product_title: 'Field Jacket',
      variant_title: 'Olive / M',
      sku: 'NB-FJ-OLV-M',
    },
    {
      product_id: '8472020',
      variant_id: '4410301',
      price: '14.50',
      currency: 'EUR',
      product_title: 'Wool Beanie',
      sku: 'NB-WB-CHR',
    },
  ],
});

Fields

FieldTypeRequired
order_idwhole number, or a string of digitsyes
subtotal_pricepriceno
total_pricepriceno
discount_amountpriceno
is_first_orderbooleanno
currencystringno
line_itemslist of line items, may be emptyno
emailstringno
phonestringno
first_namestringno
last_namestringno
address1stringno
address2stringno
citystringno
country_codestringno

order_id

A whole number, or a string that is only digits. It must fit in 9007199254740991.

An order reference like 'ORD-1024' is rejected and the event is dropped:

[TrackBee] track("checkout_completed") did not send the event. Invalid fields: order_id must be a number (a whole number up to 9007199254740991, or a string of digits), got "ORD-1024"

If your order numbers are not numeric, use the internal numeric ID your platform keeps alongside them.

Amounts

FieldWhat it is
subtotal_priceThe order total before shipping and tax
total_priceWhat the shopper actually paid, after any discount
discount_amountThe total discount on the order, as a positive amount

Send at least one of subtotal_price and total_price. Without a value the order has no revenue attached, and an order with no revenue is worth little to the platforms optimizing against it.

Do not pass discount_amount as a negative number.

is_first_order

true when this is the shopper's first order with the store, false when it is not. It has to be a boolean, so 'true' and 1 are both rejected and drop the event.

Leave it out when you do not know. Defaulting it to false tells the platforms this is a returning customer, which is worse than telling them nothing.

Customer fields

email, phone, first_name, last_name, address1, address2, city and country_code are what your ad platforms match against their own users to credit the order to an ad. Send what the order has. These are the shipping address.

country_code is a two-letter ISO code like NL or US. phone should be in international format.

This event takes no billing address. If you have one, send it on payment_info_submitted.

Set currency on every line item

Line items do not inherit the currency you set on the order. Set it on each line.

Send it once

Order confirmation pages get refreshed, bookmarked and reopened from email. Each one sends the event again, and each one counts as another order.

Guard it. Record the order ID when you send, and skip if it comes round again:

const key = 'tb_sent_order_' + orderId;

if (!sessionStorage.getItem(key)) {
  trackbee.track('checkout_completed', { order_id: orderId, /* ... */ });
  sessionStorage.setItem(key, '1');
}

sessionStorage covers a refresh in the same tab. If confirmations are reachable later, from an account page or an email link, use something that outlives the session, or suppress the event there.

The minimum

trackbee.track('checkout_completed', {
  order_id: 5512049,
  total_price: '68.49',
  currency: 'EUR',
});

On this page