Introduction
InitiateCheckout events track when users begin the checkout process. This guide explains when and how to implement InitiateCheckout events to track checkout starts.
When to Fire InitiateCheckout
Fire InitiateCheckout events when:
- Checkout Button Clicked: User clicks "Checkout" or "Proceed to Checkout"
- Checkout Page Loads: User enters the checkout page
- Checkout Started: User begins the checkout process
Fire once per checkout session - typically when user first enters checkout.
Parameter Structure
InitiateCheckout events should include:
- content_ids (required): Array of product IDs in cart
- content_type (required): Type (typically "product")
- value (optional): Total cart value
- currency (optional): Currency code (required if value provided)
- num_items (optional): Total number of items in cart
- contents (optional): Array of all items in cart
Implementation Example
// On checkout page load or checkout button click
function initiateCheckout(cartItems, totalValue) {
const contentIds = cartItems.map(item => item.id);
const contents = cartItems.map(item => ({
id: item.id,
quantity: item.quantity,
item_price: item.price
}));
const totalItems = cartItems.reduce((sum, item) => sum + item.quantity, 0);
const userData = {
country: "US"
// Add email, phone if available
};
st('track', 'InitiateCheckout', {
content_ids: contentIds,
content_type: 'product',
value: totalValue,
currency: 'USD',
num_items: totalItems,
contents: contents
}, userData);
}
Cart Contents
Include all items currently in the cart:
- All Products: Include all items the user is checking out with
- Quantities: Include correct quantities for each item
- Prices: Use current prices at time of checkout
Value Calculation
Calculate total cart value including:
- Item Subtotal: Sum of all items (price × quantity)
- Shipping: Include shipping costs if known
- Taxes: Include taxes if applicable
- Total: Final total amount user will pay
Best Practices
- Fire Once Per Session: Fire when checkout starts, not on every page view
- Include All Items: Include all items in cart, not just one
- Accurate Totals: Use actual cart totals including shipping/taxes
- Complete Data: Include contents array for detailed tracking
Summary
InitiateCheckout events track checkout starts. Include content_ids for all items in cart, value (total cart value), currency, num_items, and contents array. Fire when user begins checkout process.