// Define a function to check for the property function checkForSmartomatoWidget() { if (window.hasOwnProperty('smartomatoWidget')) { $(window).on('sm-click-pay', () => { const _tmr = window._tmr || (window._tmr = []); _tmr.push({ type: 'reachGoal', id: 3332637, goal: 'sm-click-pay' }); }); $(window).on('sm-click-checkout', () => { const _tmr = window._tmr || (window._tmr = []); _tmr.push({ type: 'reachGoal', id: 3332637, goal: 'sm-click-checkout' }); }); $(window).on('sm-finish-checkout', () => { const _tmr = window._tmr || (window._tmr = []); _tmr.push({ type: 'reachGoal', id: 3332637, goal:'sm-finish-checkout' }); }); $(window).on('sm-address-autodetect', () => { const _tmr = window._tmr || (window._tmr = []); _tmr.push({ type: 'reachGoal', id: 3332637, goal: 'sm-address-autodetect' }); }); $(window).on('sm-show-delivery-zones', () => { const _tmr = window._tmr || (window._tmr = []); _tmr.push({ type: 'reachGoal', id: 3332637, goal: 'sm-show-delivery-zones' }); }); $(window).on('sm-dish-add', () => { const _tmr = window._tmr || (window._tmr = []); _tmr.push({ type: 'reachGoal', id: 3332637, goal: 'sm-dish-add' }); }); $(window).on('sm-dish-click', () => { const _tmr = window._tmr || (window._tmr = []); _tmr.push({ type: 'reachGoal', id: 3332637, goal: 'sm-dish-click' }); }); $(window).on('sm-open-configurator', () => { const _tmr = window._tmr || (window._tmr = []); _tmr.push({ type: 'reachGoal', id: 3332637, goal: 'sm-open-configurator' }); }); $(window).on('sm-open-quick-configurator', () => { const _tmr = window._tmr || (window._tmr = []); _tmr.push({ type: 'reachGoal', id: 3332637, goal: 'sm-open-quick-configurator' }); }); $(window).on('sm-open-modal-order', () => { const _tmr = window._tmr || (window._tmr = []); _tmr.push({ type: 'reachGoal', id: 3332637, goal: 'sm-open-modal-order' }); }); $(window).on('sm-open-modal-receipt', () => { const _tmr = window._tmr || (window._tmr = []); _tmr.push({ type: 'reachGoal', id: 3332637, goal: 'sm-open-modal-receipt' }); }); clearInterval(intervalId); // Stop the interval when the widget is found } } // Set an interval to check for the property every 100 milliseconds (0.1 seconds) const intervalId = setInterval(checkForSmartomatoWidget, 100);