1var Reachgoal = { 2 initialize: { 3 AddProduct: {}, 4 RemoveProduct: {}, 5 Order: {}, 6 Ajaxform: {}, 7 FetchIt: [], 8 }, 9 goal: function (service, service_id, goal_name, goal_category) { 10 switch (service) { 11 case 'metrika': 12 if (typeof ym != 'undefined') { 13 ym(service_id, 'reachGoal', goal_name); 14 } else { 15 window['yaCounter' + service_id].reachGoal(goal_name); 16 } 17 18 break; 19 20 case 'gtag': 21 if (goal_category) { 22 gtag('event', goal_name, {event_category: goal_category}); 23 } else { 24 gtag('event', goal_name); 25 } 26 break; 27 28 case 'gtm': 29 if (goal_category) { 30 dataLayer.push({'event': 'event-to-ga', 'eventCategory' : goal_category, 'eventAction' : goal_name}); 31 } else { 32 dataLayer.push({'event': 'event-to-ga', 'eventAction' : goal_name}); 33 } 34 break; 35 } 36 } 37} 38 39window.onload = function () { 40 if (typeof miniShop2 != 'undefined') { 41 miniShop2.Callbacks.Cart.add.response.success = function() { 42 if (typeof Reachgoal.initialize.AddProduct != 'undefined') { 43 Reachgoal.initialize.AddProduct.forEach(function(item) { 44 Reachgoal.goal(item.service, item.service_id, item.goal_name, item.goal_category); 45 }); 46 } 47 }; 48 49 miniShop2.Callbacks.Cart.remove.response.success = function() { 50 if (typeof Reachgoal.initialize.RemoveProduct != 'undefined') { 51 Reachgoal.initialize.RemoveProduct.forEach(function(item) { 52 Reachgoal.goal(item.service, item.service_id, item.goal_name, item.goal_category); 53 }); 54 } 55 }; 56 57 miniShop2.Callbacks.Order.submit.response.success = function() { 58 if (typeof Reachgoal.initialize.Order != 'undefined') { 59 Reachgoal.initialize.Order.forEach(function(item) { 60 Reachgoal.goal(item.service, item.service_id, item.goal_name, item.goal_category); 61 }); 62 } 63 } 64 } 65 66 if ( 67 (window.$ || window.jQuery) 68 && Reachgoal.initialize.Ajaxform 69 ) { 70 $(document).on('af_complete', function(event, response) { 71 if (!response.success) { 72 return; 73 } 74 75 Reachgoal.initialize.AjaxForm.forEach(function(item) { 76 if (response.form.attr('id') !== item.form_id) { 77 return; 78 } 79 80 Reachgoal.goal(item.service, item.service_id, item.goal_name, item.goal_category); 81 }); 82 }); 83 } 84}; 85 86if (Reachgoal.initialize.FetchIt) { 87 document.addEventListener('fetchit:success', ({ detail }) => { 88 const { form } = detail; 89 90 Reachgoal.initialize.FetchIt.forEach((item) => { 91 if (!form.matches(item.form_selector)) { 92 return; 93 } 94 95 Reachgoal.goal(item.service, item.service_id, item.goal_name, item.goal_category); 96 }) 97 }) 98}
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.