Skip to main content

checkout_started
interface

The checkout_started event logs an instance of a customer starting the checkout process. This event is available on the checkout page. For Checkout Extensibility, this event is triggered every time a customer enters checkout. For non-checkout extensible shops, this event is only triggered the first time a customer enters checkout.

string

The client-side ID of the customer, provided by Shopify

string

The ID of the customer event

string

The name of the customer event

number

The sequence index number of the event.

string

The timestamp of when the customer event occurred, in ISO 8601 format

.Standard
Was this section helpful?

Accessing Standard Events

import {register} from '@shopify/web-pixels-extension';

register(({analytics}) => {
analytics.subscribe('checkout_started', (event) => {
// Example for accessing event data
const checkout = event.data.checkout;

const checkoutTotalPrice = checkout.totalPrice?.amount;

const allDiscountCodes = checkout.discountApplications.map((discount) => {
if (discount.type === 'DISCOUNT_CODE') {
return discount.title;
}
});

const firstItem = checkout.lineItems[0];

const firstItemDiscountedValue = firstItem.discountAllocations[0]?.amount;

const customItemPayload = {
quantity: firstItem.quantity,
title: firstItem.title,
discount: firstItemDiscountedValue,
};

const payload = {
event_name: event.name,
event_data: {
totalPrice: checkoutTotalPrice,
discountCodesUsed: allDiscountCodes,
firstItem: customItemPayload,
},
};

// Example for sending event data to third party servers
fetch('https://example.com/pixel', {
method: 'POST',
body: JSON.stringify(payload),
keepalive: true,
});
});
});