Skip to main content

Track custom add-to-cart buttons

Send an add-to-cart event to Venon from a custom button with window.VenonATC.

Written by Venon

If your custom add-to-cart flow needs a manual Venon event, your developer can call window.VenonATC(productId, quantity). This records the event. It does not add a product to the cart.
​

1. Load the Venon script

  1. Make sure the Venon tracking script loads on the page that contains the custom button. For an external page, follow Track external landing pages.

  2. Wait until the script has loaded before calling window.VenonATC. The script loads asynchronously.

The function should be available in the browser as window.VenonATC.
​

2. Call Venon after the cart update succeeds

  1. Find the success handler for your existing add-to-cart operation.

  2. Pass the Shopify product ID as a string or number, and the quantity added as a number. Use the product ID, not the variant ID.

  3. Call the function once for the successful addition. Do not call it again from a second click handler for the same action.

// Inside your existing successful add-to-cart handler:
if (typeof window.VenonATC === "function") {
window.VenonATC(productId, quantityAdded);
}

Replace productId and quantityAdded with values from your own cart code. The guard avoids an error if the script is unavailable, but it does not queue the event for later.
​

3. Test the custom flow

  1. Open a product page and use the custom button to add a product. Confirm the cart actually updates.

  2. In your browser developer tools, open the network panel and check the Venon request to /api/feedback. The event payload should contain name: "atc", the product ID, and the quantity.

  3. Check that the same successful action does not call window.VenonATC more than once.

The script also tries to read /cart.js for cart details. A headless storefront may not expose this Shopify endpoint, so do not assume the event will include full cart contents. Tracking Checker tests page views only, not this add-to-cart call.

Did this answer your question?