TrackBee DocsTrackBee Docs
Tracking SDKEvents

add_to_cart

Someone added a product to the cart.

Send this when a product is added to the cart, once per add.

trackbee.track('add_to_cart', {
  product_id: '8472019',
  variant_id: '4410228',
  price: '29.99',
  quantity: 2,
  currency: 'EUR',
  product_title: 'Field Jacket',
  variant_title: 'Olive / M',
  product_type: 'Outerwear',
  product_url: 'https://example.com/products/field-jacket',
  vendor: 'Northbound',
  sku: 'NB-FJ-OLV-M',
});

Fields

FieldTypeRequired
product_idstring or numberyes
variant_idstring or numberyes
pricepriceyes
quantitywhole number, at least 1no, defaults to 1
currencystringno
product_titlestringno
variant_titlestringno
product_typestringno
product_urlstringno
vendorstringno
skustringno

The same fields as product_view, plus quantity and minus image_url.

Price and quantity

price is the unit price, not the line total. Pass the quantity separately and the SDK works out the total itself.

// Two jackets at 29.99 each
trackbee.track('add_to_cart', {
  product_id: '8472019',
  variant_id: '4410228',
  price: '29.99',
  quantity: 2,
  currency: 'EUR',
});

Leave quantity out and it counts as 1.

The total is rounded to the same number of decimals as the price you passed, so '0.10' with a quantity of 3 sends 0.3 rather than the 0.30000000000000004 plain multiplication gives you.

No image

image_url is accepted on product_view but not here. Passing it does nothing, and you get no warning. See misspelled fields.

On this page