1const GAEventTimeout = 1500; 2 3/** 4 * Fire google analytics events 5 * 6 * @param {string} category 7 * @param {string} action 8 * @param {string} label 9`* @param {string} redirect_url 10 * @param {string} value 11 */ 12var SendGAEvent = function(category, action, label = null, redirect_url = null, value = null, ux = null, form_id = null) { 13 let fired = false; 14 let timeoutId; 15 16 const callback = function() { 17 if (!fired) { 18 fired = true; 19 clearTimeout(timeoutId); 20 if (form_id) { 21 document.getElementById(form_id).submit(); 22 } else if (redirect_url) { 23 window.location = redirect_url; 24 } 25 } 26 }; 27 28 const payload = { 29 'event_category': category, 30 'event_label': label, 31 'event_value': value, 32 'event_callback' : callback, 33 'event_ux': ux, 34 }; 35 36 if (typeof window.gtag !== 'function' || !window.ga || !window.ga.loaded) { 37 callback(); 38 } else { 39 gtag( 40 'event', 41 action, 42 payload 43 ); 44 45 timeoutId = setTimeout(callback, GAEventTimeout); 46 } 47}; 48 49/** 50 * Fire google analytics E-commerce event 51 * 52 * @param {int} order_id 53 * @param {bool} total 54 * @param {json} items 55 */ 56var SendGAPurchaseEvent= function(order_id, total, items) { 57 var item_list = JSON.parse(items); 58 59 gtag('event', 'purchase', { 60 "transaction_id": order_id, 61 "affiliation": "Dog Academy", 62 "value": total, 63 "currency": "USD", 64 "who_variant": "SELF", 65 "items": item_list, 66 }); 67}; 68 69/** 70 * Event listeners for 71 * livewire 72 */ 73 74window.addEventListener('send-ga-event', event => { 75 SendGAEvent(event.detail.category, event.detail.action, event.detail.label, null, event.detail.value, event.detail.ux); 76}); 77 78window.addEventListener('send-ga-purchase-event', event => { 79 SendGAPurchaseEvent(event.detail.order_id, event.detail.total, event.detail.items); 80});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.