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.
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,
});
});
});
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,
});
});
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.
The client-side ID of the customer, provided by Shopify
The ID of the customer event
The name of the customer event
The timestamp of when the customer event occurred, in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format
A snapshot of various read-only properties of the browser at the time of event
Snapshot of a subset of properties of the `document` object in the top frame of the browser
Snapshot of a subset of properties of the `navigator` object in the top frame of the browser
Snapshot of a subset of properties of the `window` object in the top frame of the browser
A snapshot of a subset of properties of the `document` object in the top frame of the browser
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document), returns the character set being used by the document
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document), returns the URI of the current document
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document), returns the URI of the page that linked to this page
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document), returns the title of the current document
A snapshot of a subset of properties of the `location` object in the top frame of the browser
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing a `'#'` followed by the fragment identifier of the URL
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the host, that is the hostname, a `':'`, and the port of the URL
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the domain of the URL
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the entire URL
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the canonical form of the origin of the specific location
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing an initial `'/'` followed by the path of the URL, not including the query string or fragment
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the port number of the URL
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing the protocol scheme of the URL, including the final `':'`
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Location), a string containing a `'?'` followed by the parameters or "querystring" of the URL
A snapshot of a subset of properties of the `navigator` object in the top frame of the browser
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Navigator), returns `false` if setting a cookie will be ignored and true otherwise
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Navigator), returns a string representing the preferred language of the user, usually the language of the browser UI. The `null` value is returned when this is unknown
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Navigator), returns an array of strings representing the languages known to the user, by order of preference
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Navigator), returns the user agent string for the current browser
A snapshot of a subset of properties of the `window` object in the top frame of the browser
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), gets the height of the content area of the browser window including, if rendered, the horizontal scrollbar
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), gets the width of the content area of the browser window including, if rendered, the vertical scrollbar
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the location, or current URL, of the window object
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the global object's origin, serialized as a string
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), gets the height of the outside of the browser window
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), gets the width of the outside of the browser window
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), an alias for window.scrollX
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), an alias for window.scrollY
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Screen), the interface representing a screen, usually the one on which the current window is being rendered
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the horizontal distance from the left border of the user's browser viewport to the left side of the screen
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the vertical distance from the top border of the user's browser viewport to the top side of the screen
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the number of pixels that the document has already been scrolled horizontally
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Window), the number of pixels that the document has already been scrolled vertically
The interface representing a screen, usually the one on which the current window is being rendered
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Screen/height), the height of the screen
Per [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Screen/width), the width of the screen
A container for all the information required to add items to checkout and pay.
A list of attributes accumulated throughout the checkout process.
The billing address to where the order will be charged.
Indicates whether the customer has consented to be sent marketing material via email. This property is only available if the shop has [upgraded to Checkout Extensibility](https://help.shopify.com/en/manual/checkout-settings/checkout-extensibility/checkout-upgrade).
Indicates whether the customer has consented to be sent marketing material via SMS. This property is only available if the shop has [upgraded to Checkout Extensibility](https://help.shopify.com/en/manual/checkout-settings/checkout-extensibility/checkout-upgrade).
The three-letter code that represents the currency, for example, USD. Supported codes include standard ISO 4217 codes, legacy codes, and non- standard codes.
Represents the selected delivery options for a checkout. This property is only available if the shop has [upgraded to Checkout Extensibility](https://help.shopify.com/en/manual/checkout-settings/checkout-extensibility/checkout-upgrade).
A list of discount applications.
The total amount of the discounts applied to the price of the checkout. This property is only available if the shop has [upgraded to Checkout Extensibility](https://help.shopify.com/manual/checkout-settings/checkout-extensibility/checkout-upgrade).
The email attached to this checkout.
A list of line item objects, each one containing information about an item in the checkout.
Information about the active localized experience. This property is only available if the shop has [upgraded to Checkout Extensibility](https://help.shopify.com/en/manual/checkout-settings/checkout-extensibility/checkout-upgrade).
The resulting order from a paid checkout.
A unique phone number for the customer. Formatted using E.164 standard. For example, *+16135551111*.
The shipping address to where the line items will be shipped.
Once a shipping rate is selected by the customer it is transitioned to a `shipping_line` object.
The phone number provided by the buyer after opting in to SMS marketing. This property is only available if the shop has [upgraded to Checkout Extensibility](https://help.shopify.com/en/manual/checkout-settings/checkout-extensibility/checkout-upgrade).
The price at checkout before duties, shipping, and taxes.
A unique identifier for a particular checkout.
The sum of all the prices of all the items in the checkout, including duties, taxes, and discounts.
The sum of all the taxes applied to the line items and shipping lines in the checkout.
A list of transactions associated with a checkout or order. Certain transactions, such as credit card transactions, may only be present in the checkout_completed event.
Custom attributes associated with the cart or checkout.
The key for the attribute.
The value for the attribute.
A mailing address for customers and shipping.
The first line of the address. This is usually the street address or a P.O. Box number.
The second line of the address. This is usually an apartment, suite, or unit number.
The name of the city, district, village, or town.
The name of the country.
The two-letter code that represents the country, for example, US. The country codes generally follows ISO 3166-1 alpha-2 guidelines.
The customer’s first name.
The customer’s last name.
The phone number for this mailing address as entered by the customer.
The region of the address, such as the province, state, or district.
The two-letter code for the region. For example, ON.
The ZIP or postal code of the address.
The delivery information for the event.
The selected delivery options for the event.
Represents a delivery option that the customer can choose from.
The cost of the delivery option.
The cost of the delivery option after discounts have been applied.
The description of the delivery option.
The unique identifier of the delivery option.
The title of the delivery option.
The type of delivery option. - `pickup` - `pickupPoint` - `shipping` - `local`
A monetary value with currency.
The decimal money amount.
The three-letter code that represents the currency, for example, USD. Supported codes include standard ISO 4217 codes, legacy codes, and non- standard codes.
The information about the intent of the discount.
The method by which the discount's value is applied to its entitled items. - `ACROSS`: The value is spread across all entitled lines. - `EACH`: The value is applied onto every entitled line.
How the discount amount is distributed on the discounted lines. - `ALL`: The discount is allocated onto all the lines. - `ENTITLED`: The discount is allocated onto only the lines that it's entitled for. - `EXPLICIT`: The discount is allocated onto explicitly chosen lines.
The type of line (i.e. line item or shipping line) on an order that the discount is applicable towards. - `LINE_ITEM`: The discount applies onto line items. - `SHIPPING_LINE`: The discount applies onto shipping lines.
The customer-facing name of the discount. If the type of discount is a `DISCOUNT_CODE`, this `title` attribute represents the code of the discount.
The type of the discount. - `AUTOMATIC`: A discount automatically at checkout or in the cart without the need for a code. - `DISCOUNT_CODE`: A discount applied onto checkouts through the use of a code. - `MANUAL`: A discount that is applied to an order by a merchant or store owner manually, rather than being automatically applied by the system or through a script. - `SCRIPT`: A discount applied to a customer's order using a script
The value of the discount. Fixed discounts return a `Money` Object, while Percentage discounts return a `PricingPercentageValue` object.
A value given to a customer when a discount is applied to an order. The application of a discount with this value gives the customer the specified percentage off a specified item.
The percentage value of the object.
A single line item in the checkout, grouped by variant and attributes.
The discounts that have been applied to the checkout line item by a discount application.
The combined price of all of the items in the line item after line-level discounts have been applied. This property is only available if the shop has [upgraded to Checkout Extensibility](https://help.shopify.com/manual/checkout-settings/checkout-extensibility/checkout-upgrade).
A globally unique identifier.
The properties of the line item. A shop may add, or enable customers to add custom information to a line item. Line item properties consist of a key and value pair. This property is only available if the shop has [upgraded to Checkout Extensibility](https://help.shopify.com/manual/checkout-settings/checkout-extensibility/checkout-upgrade).
The quantity of the line item.
The selling plan associated with the line item and the effect that each selling plan has on variants when they're purchased. This property is only available if the shop has [upgraded to Checkout Extensibility](https://help.shopify.com/manual/checkout-settings/checkout-extensibility/checkout-upgrade).
The title of the line item. Defaults to the product's title.
Product variant of the line item.
The discount that has been applied to the checkout line item.
The monetary value with currency allocated to the discount.
The information about the intent of the discount.
The line item additional custom properties.
The key for the property.
The value for the property.
Represents an association between a variant and a selling plan.
A representation of how products and variants can be sold and purchased. For example, an individual selling plan could be '6 weeks of prepaid granola, delivered weekly'.
Represents how products and variants can be sold and purchased.
A globally unique identifier.
The name of the selling plan. For example, '6 weeks of prepaid granola, delivered weekly'.
A product variant represents a different version of a product, such as differing sizes or differing colors.
A globally unique identifier.
Image associated with the product variant. This field falls back to the product image if no image is available.
The product variant’s price.
The product object that the product variant belongs to.
The SKU (stock keeping unit) associated with the variant.
The product variant’s title.
The product variant’s untranslated title.
An image resource.
The location of the image as a URL.
A product is an individual item for sale in a Shopify store.
The ID of the product.
The product’s title.
The [product type](https://help.shopify.com/en/manual/products/details/product-type) specified by the merchant.
The product’s untranslated title.
The relative URL of the product.
The product’s vendor name.
Information about the active localized experience.
The country of the active localized experience.
The language of the active localized experience.
The market including the country of the active localized experience.
A country.
The ISO-3166-1 code for this country, for example, "US".
A language.
The BCP-47 language tag. It may contain a dash followed by an ISO 3166-1 alpha-2 region code, for example, "en-US".
A group of one or more regions of the world that a merchant is targeting for sales. To learn more about markets, refer to [this](https://shopify.dev/docs/apps/markets) conceptual overview.
A human-readable, shop-scoped identifier.
A globally unique identifier.
An order is a customer’s completed request to purchase one or more products from a shop. An order is created when a customer completes the checkout process.
The customer that placed the order.
The ID of the order. ID will be null for all events except checkout_completed.
The customer that placed the order.
The ID of the customer.
Indicates if the order is the customer’s first order. This property is only available if the shop has [upgraded to Checkout Extensibility](https://help.shopify.com/en/manual/checkout-settings/checkout-extensibility/checkout-upgrade).
A shipping rate to be applied to a checkout.
Price of this shipping rate.
A transaction associated with a checkout or order.
The monetary value with currency allocated to the transaction method.
The name of the payment provider used for the transaction.
The payment method used for the transaction. This property is only available if the shop has [upgraded to Checkout Extensibility](https://help.shopify.com/en/manual/checkout-settings/checkout-extensibility/checkout-upgrade).
The payment method used for the transaction. This property is only available if the shop has [upgraded to Checkout Extensibility](https://help.shopify.com/en/manual/checkout-settings/checkout-extensibility/checkout-upgrade).
The name of the payment method used for the transaction. This may further specify the payment method used.
The type of payment method used for the transaction. - `creditCard`: A vaulted or manually entered credit card. - `redeemable`: A redeemable payment method, such as a gift card or store credit. - `deferred`: A [deferred payment](https://help.shopify.com/en/manual/orders/deferred-payments), such as invoicing the buyer and collecting payment later. - `local`: A [local payment method](https://help.shopify.com/en/manual/payments/shopify-payments/local-payment-methods) specific to the current region or market. - `manualPayment`: A manual payment method, such as an in-person retail transaction. - `paymentOnDelivery`: A payment that will be collected on delivery. - `wallet`: An integrated wallet, such as PayPal, Google Pay, Apple Pay, etc. - `offsite`: A payment processed outside of Shopify's checkout, excluding integrated wallets. - `customOnSite`: A custom payment method that is processed through a checkout extension with a payments app. - `other`: Another type of payment not defined here.