Trust Guard Security Scanned
Accurate Precious Metals: Coins, Jewelry & Diamonds
Filters
jQuery(function ($) { // Single product page (AJAX or form submit) $('form.cart').on('submit', function (e) { // Get product ID and quantity from form var $form = $(this); var product_id = $form.find('button[name="add-to-cart"]').val(); var quantity = parseInt($form.find('input.qty').val(), 10) || 1; // Push to dataLayer with a slight delay to let WooCommerce process setTimeout(function () { window.dataLayer = window.dataLayer || []; window.dataLayer.push({ event: 'add_to_cart', source: 'single_product', product_id: product_id, quantity: quantity }); }, 300); // 300ms delay }); });