Custom events
STOQ emits custom events that you can listen to for custom integrations. All events are dispatched on the window object (except where noted) and include detailed information in the event.detail property.
stoq:loaded
stoq:loadedEvent name: stoq:loaded
Description: Event triggered when STOQ's app embed is loaded on any page supported by the app. Pages supported: Product, Collection, Home, Search.
Event target: window
Event detail:
pageType(string): The type of page where the app loaded. Possible values:'product','collection','index','search','page'enabled(boolean): Whether the app is enabled for this pagesettings(object): Complete app settings object containing all configuration options
Example:
window.addEventListener('stoq:loaded', (event) => {
const { pageType, enabled, settings } = event.detail;
if (pageType === 'product' && enabled) {
console.log('Stoq loaded on product page', settings);
// Handle product page customizations
}
});stoq:restock-modal:opened
stoq:restock-modal:openedEvent name: stoq:restock-modal:opened
Description: Event triggered when the restock notification modal is opened. This occurs when a customer clicks the "Notify Me" button for an out-of-stock product.
Event target: window
Event detail:
action(string): Always'opened'product(object): Product data object containing product informationvariant(object): Variant data object containing variant information
Example:
stoq:restock-modal:submitted
stoq:restock-modal:submittedEvent name: stoq:restock-modal:submitted
Description: Event triggered when a customer successfully submits the restock notification form. This occurs after the form validation passes and the notification request is created.
Event target: window
Event detail:
action(string): Always'submitted'product(object): Product data object containing product informationvariant(object): Variant data object containing variant informationcustomer(object): Customer information objectemail(string|null): Customer email address if providedphone(string|null): Customer phone number if provided
Example:
stoq:restock-modal:closed
stoq:restock-modal:closedEvent name: stoq:restock-modal:closed
Description: Event triggered when the restock notification modal is closed, either by the user clicking the close button or clicking outside the modal.
Event target: window
Event detail:
action(string): Always'closed'product(object): Product data object containing product informationvariant(object): Variant data object containing variant information
Example:
stoq:preorder-modal:opened
stoq:preorder-modal:openedEvent name: stoq:preorder-modal:opened
Description: Event triggered when the preorder modal is opened. This occurs when a customer clicks a preorder button or attempts to add a preorder product to cart.
Event target: window
Event detail:
productData(object): Complete product data objectvariantId(string|number): ID of the selected variantsellingPlan(object|null): Selling plan object if a specific plan is selected, null otherwise
Example:
stoq:preorder-modal:closed
stoq:preorder-modal:closedEvent name: stoq:preorder-modal:closed
Description: Event triggered when the preorder modal is closed. This can occur in two scenarios: when the customer accepts the preorder (adds to cart) or when they reject/close the modal.
Event target: window
Event detail:
action(string): Either'accepted'or'rejected'indicating how the modal was closedproductData(object): Complete product data objectvariantId(string|number): ID of the selected variantselectedSellingPlanId(number|null): ID of the selected selling plan if accepted, null if rejectedsellingPlan(object|null): Selling plan objectquantity(number): Quantity selected (only present whenaction === 'accepted')acknowledgedPreorder(boolean): Whether the customer acknowledged the preorder terms (only present whenaction === 'accepted')
Example:
stoq:preorder-payment-option:selected
stoq:preorder-payment-option:selectedEvent name: stoq:preorder-payment-option:selected
Description: Event triggered when a customer selects a different payment option (selling plan) in the preorder payment widget. This event bubbles from the payment widget element.
Event target: Payment widget element (bubbles to window)
Event detail:
paymentWidget(HTMLElement): The DOM element containing the payment widgetvariantId(string|number): ID of the variant for which the payment option was selectedselectedSellingPlanId(number): ID of the newly selected selling plan
Example:
stoq:product-changed
stoq:product-changedEvent name: stoq:product-changed
Description: Event triggered when the product context changes, such as when navigating to a different product or when the variant selection changes significantly. This is useful for tracking product views and updating custom integrations.
Event target: document
Event detail:
productHandle(string): The Shopify product handle (URL slug)productId(string|number): The Shopify product IDvariantId(string|number): The currently selected variant ID
Example:
Integration examples
Track all modal interactions
Update custom UI on product change
React to payment option changes
Last updated