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
| Field | Type | Required |
|---|---|---|
product_id | string or number | yes |
variant_id | string or number | yes |
price | price | yes |
quantity | whole number, at least 1 | no, defaults to 1 |
currency | string | no |
product_title | string | no |
variant_title | string | no |
product_type | string | no |
product_url | string | no |
vendor | string | no |
sku | string | no |
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.