Track ecommerce events
Required and optional fields, product details, and examples for all 14 trackEcommerce events.
trackEcommerce records store actions using 14 defined event names. The exact spelling is trackEcommerce, with two “m” letters. The Pixel does not automatically extract products, prices, or orders from your website.
Before sending
- Install the Pixel and connect consent.
- Have your store developer retrieve actual product, cart, and order data.
- Connect each call to the action listed below. Wait for your system to confirm purchases and refunds.
- Send once per action and verify the result.
Signature
window.CJMPixel.trackEcommerce(eventName, data, options?)
eventName and data are required. Optional options accepts tags and destinations, documented under custom events. Meta/GTM destinations are off by default.
Fields for each event
All listed fields belong inside data. currency is required for all 14 events, even without a monetary value. Use a string such as EUR. items is an array of products, required except for refund.
| Event | When to send | Required | Optional |
|---|---|---|---|
view_item_list | Display a product list | currency, items | item_list_id, item_list_name |
select_item | Select a product from a list | currency, items | item_list_id, item_list_name |
view_item | Display a product | currency, items | value |
add_to_cart | Successful add to cart | currency, items | value |
add_to_wishlist | Successful add to wishlist | currency, items | value |
remove_from_cart | Successful removal from cart | currency, items | value |
view_cart | Display the cart | currency, items | value |
begin_checkout | Start checkout | currency, items | value, coupon |
add_shipping_info | Confirm shipping details | currency, items | value, coupon, shipping_tier |
add_payment_info | Confirm payment method | currency, items | value, coupon, payment_type |
purchase | Confirmed purchase | currency, transaction_id, value, items | coupon, shipping, tax, customer_type |
refund | Confirmed refund | currency, transaction_id | value, coupon, shipping, tax, items |
view_promotion | Display a promotion | currency, items | creative_name, creative_slot, promotion_id, promotion_name |
select_promotion | Select a promotion | currency, items | creative_name, creative_slot, promotion_id, promotion_name |
value, shipping, and tax are numbers, not strings containing a currency symbol. Use a decimal point. Other event fields are strings; customer_type accepts only new or returning.
Use the product value for this event as value, consistent with price × quantity; specify shipping and tax separately. Do not scrape a formatted total from page text. The Pixel does not calculate totals, fill missing fields, or convert currencies.
transaction_id identifies the real order and must match for its refund. The Pixel does not prevent two purchase calls for the same order: avoid resending when the confirmation page reloads.
Every product field
Each object in items requires both item_id and item_name in the CJM contract. Optional fields receive no automatic values: supply price and quantity to describe an amount.
| Field | Type | Required | Meaning |
|---|---|---|---|
item_id | string | Yes | Product code / SKU |
item_name | string | Yes | Product name |
affiliation | string | No | Store or affiliation |
coupon | string | No | Item coupon |
discount | number | No | Unit discount |
index | number | No | Position in list |
item_brand | string | No | Brand |
item_category | string | No | Main category |
item_category2, item_category3, item_category4, item_category5 | string | No | Further category levels |
item_list_id, item_list_name | string | No | List ID and name |
item_variant | string | No | Variant, e.g. color or size |
location_id | string | No | Store location ID |
price | number | No | Unit price |
quantity | number | No | Quantity |
promotion_id, promotion_name | string | No | Promotion ID and name |
google_business_vertical | string | No | Business vertical |
Minimal examples for each event
These calls show only required fields. Choose the call for the action you are integrating; do not execute this block as a sequence. Use the complete examples below to include prices and quantities.
window.CJMPixel.trackEcommerce('view_item_list', { currency: 'EUR', items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });
window.CJMPixel.trackEcommerce('select_item', { currency: 'EUR', items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });
window.CJMPixel.trackEcommerce('view_item', { currency: 'EUR', items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });
window.CJMPixel.trackEcommerce('add_to_cart', { currency: 'EUR', items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });
window.CJMPixel.trackEcommerce('add_to_wishlist', { currency: 'EUR', items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });
window.CJMPixel.trackEcommerce('remove_from_cart', { currency: 'EUR', items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });
window.CJMPixel.trackEcommerce('view_cart', { currency: 'EUR', items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });
window.CJMPixel.trackEcommerce('begin_checkout', { currency: 'EUR', items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });
window.CJMPixel.trackEcommerce('add_shipping_info', { currency: 'EUR', items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });
window.CJMPixel.trackEcommerce('add_payment_info', { currency: 'EUR', items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });
window.CJMPixel.trackEcommerce('purchase', { currency: 'EUR', transaction_id: 'ORD-2026-1001', value: 89.9, items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });
window.CJMPixel.trackEcommerce('refund', { currency: 'EUR', transaction_id: 'ORD-2026-1001' });
window.CJMPixel.trackEcommerce('view_promotion', { currency: 'EUR', items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });
window.CJMPixel.trackEcommerce('select_promotion', { currency: 'EUR', items: [{ item_id: 'SKU-001', item_name: 'Backpack' }] });Examples for all 14 events
Each example is independent and includes required and optional event fields. Do not run the whole sequence on page load. Replace sample names and values with actual data.
view_item_list
window.CJMPixel.trackEcommerce('view_item_list', {
"currency": "EUR",
"item_list_id": "catalogo",
"item_list_name": "Catalogo",
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});select_item
window.CJMPixel.trackEcommerce('select_item', {
"currency": "EUR",
"item_list_id": "catalogo",
"item_list_name": "Catalogo",
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});view_item
window.CJMPixel.trackEcommerce('view_item', {
"currency": "EUR",
"value": 89.9,
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});add_to_cart
window.CJMPixel.trackEcommerce('add_to_cart', {
"currency": "EUR",
"value": 89.9,
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});add_to_wishlist
window.CJMPixel.trackEcommerce('add_to_wishlist', {
"currency": "EUR",
"value": 89.9,
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});remove_from_cart
window.CJMPixel.trackEcommerce('remove_from_cart', {
"currency": "EUR",
"value": 89.9,
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});view_cart
window.CJMPixel.trackEcommerce('view_cart', {
"currency": "EUR",
"value": 89.9,
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});begin_checkout
window.CJMPixel.trackEcommerce('begin_checkout', {
"currency": "EUR",
"value": 89.9,
"coupon": "WELCOME",
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});add_shipping_info
window.CJMPixel.trackEcommerce('add_shipping_info', {
"currency": "EUR",
"value": 89.9,
"coupon": "WELCOME",
"shipping_tier": "Standard",
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});add_payment_info
window.CJMPixel.trackEcommerce('add_payment_info', {
"currency": "EUR",
"value": 89.9,
"coupon": "WELCOME",
"payment_type": "Card",
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});purchase
window.CJMPixel.trackEcommerce('purchase', {
"currency": "EUR",
"transaction_id": "ORD-2026-1001",
"value": 89.9,
"coupon": "WELCOME",
"shipping": 5,
"tax": 19.78,
"customer_type": "new",
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});refund
window.CJMPixel.trackEcommerce('refund', {
"currency": "EUR",
"transaction_id": "ORD-2026-1001",
"value": 89.9,
"coupon": "WELCOME",
"shipping": 5,
"tax": 19.78,
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});view_promotion
window.CJMPixel.trackEcommerce('view_promotion', {
"currency": "EUR",
"creative_name": "Autumn banner",
"creative_slot": "home_top",
"promotion_id": "AUTUMN26",
"promotion_name": "Autumn",
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});select_promotion
window.CJMPixel.trackEcommerce('select_promotion', {
"currency": "EUR",
"creative_name": "Autumn banner",
"creative_slot": "home_top",
"promotion_id": "AUTUMN26",
"promotion_name": "Autumn",
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"price": 89.9,
"quantity": 1
}
]
});Product with every field
window.CJMPixel.trackEcommerce('view_item', {
"currency": "EUR",
"value": 89.9,
"items": [
{
"item_id": "SKU-001",
"item_name": "Zaino",
"affiliation": "Online store",
"coupon": "WELCOME",
"discount": 10,
"index": 0,
"item_brand": "Example",
"item_category": "Accessories",
"item_category2": "Bags",
"item_category3": "Backpacks",
"item_category4": "Travel",
"item_category5": "Cabin",
"item_list_id": "catalogo",
"item_list_name": "Catalogo",
"item_variant": "Blue",
"location_id": "MILANO-01",
"price": 89.9,
"quantity": 1,
"promotion_id": "AUTUMN26",
"promotion_name": "Autumn",
"google_business_vertical": "retail"
}
]
});Minimal purchase and partial refund
The first example purchases two units; the second refunds only one unit from the same order. Run each call only when the corresponding operation is confirmed.
window.CJMPixel.trackEcommerce('purchase', {
currency: 'EUR',
transaction_id: 'ORD-2026-1002',
value: 179.8,
items: [{ item_id: 'SKU-001', item_name: 'Zaino', price: 89.9, quantity: 2 }]
});window.CJMPixel.trackEcommerce('refund', {
currency: 'EUR',
transaction_id: 'ORD-2026-1002',
value: 89.9,
items: [{ item_id: 'SKU-001', item_name: 'Zaino', price: 89.9, quantity: 1 }]
});Also send to GTM or Meta
Add options.destinations only when the destination is already available on the page. Forwarding requires all four consent signals. See Forwarding and duplicates.
Final checks
- Use one of the 14 exact names, including lowercase letters and underscores.
- Send actual numbers and a
dataobject, not a JSON string. - For partial refunds, send only refunded products, quantities, and amounts.
- An event named
purchasesent usingtrack()or HTML attributes is still generic. UsetrackEcommercefor ecommerce formatting. - The TypeScript contract describes accepted fields. Pasting JavaScript does not automatically validate those types. Check your data before sending.