1( 2 function ( $, window, document ) { 3 'use strict'; 4 5 $( 6 function ( $ ) { 7 8 $( document ).on( 9 // Buttons, headings, images. 10 'click', 11 '[data-wpl_tracker] a:not(.events-tracker-for-elementor-exclude)', 12 function ( event ) { 13 var $link = $( this ), 14 href = $link.attr( 'href' ), 15 target = $link.attr( 'target' ), 16 lightbox = $link.data( 'elementor-open-lightbox' ), 17 options = $link.parents( '.events-tracker-for-elementor' ).data( 'wpl_tracker' ); 18 19 // ÐÑменим пеÑÐµÑ Ð¾Ð´ по ÑÑÑлке. 20 event.preventDefault(); 21 22 /** 23 * ÐÑли еÑÑÑ ÑÑÑлка Ð´Ð»Ñ Ð¿ÐµÑÐµÑ Ð¾Ð´Ð°, добавим задеÑжкÑ, ÑÑÐ¾Ð±Ñ ÑÑекинг ÑÑпел оÑÑабоÑаÑÑ. 24 * 25 * ÐÐ°Ð³Ð¸Ñ Ð¿Ñавил: 26 * 27 * 1. `'%23' !== href.substr( 0, 3 )` - когда по кнопке оÑкÑÑваеÑÑÑ Ð¿Ð¾Ð¿Ð°Ð¿ 28 * 2. `href && '#' !== href` - когда ÑÑавÑÑ Ð¿ÑÑÑÑе ÑÑÑлки 29 * 3. `( ! lightbox || 'no' === lightbox )` - когда по кнопке оÑкÑÑваеÑÑÑ Ð»Ð°Ð¹ÑбокÑ. 30 */ 31 if ( href && '#' !== href && '%23' !== href.substr( 0, 3 ) && ( ! lightbox || 'no' === lightbox ) ) { 32 track_element( options ); 33 console.log( 'Click with link' ); 34 35 /** 36 * Open in new window. 37 * 38 * @link https://learn.javascript.ru/popup-windows 39 */ 40 if ( target && '_blank' === target ) { 41 window.open( href ); 42 } else { 43 setTimeout( 44 function () { 45 document.location.href = href; 46 }, 47 2000 48 ); 49 } 50 } else { 51 track_element( options ); 52 console.log( 'Click without link' ); 53 } 54 } 55 ); 56 57 $( document ).on( 58 // Forms. 59 'submit_success', 60 '[data-wpl_tracker] form:not(.events-tracker-for-elementor-exclude)', 61 function ( event ) { 62 var $form = $( this ), 63 options = $form.parents( '.events-tracker-for-elementor' ).data( 'wpl_tracker' ); 64 65 track_element( options ); 66 console.log( 'Submit success' ); 67 } 68 ); 69 70 function track_element( options ) { 71 if ( options.vkontakte ) { 72 track_vkontakte( options.vkontakte_event_name ); 73 } 74 75 if ( options.yandex_metrika ) { 76 track_yandex_metrika( options.yandex_metrika_event_name, options.yandex_metrika_id ); 77 } 78 79 if ( options.gtag ) { 80 track_gtag( options.gtag_category, options.gtag_action, options.gtag_label ); 81 } 82 83 if ( options.adwords ) { 84 track_adwords( options.adwords_id, options.adwords_label, options.adwords_currency, options.adwords_value ); 85 } 86 87 if ( options.analytics ) { 88 track_analytics( options.analytics_category, options.analytics_action, options.analytics_label ); 89 } 90 91 if ( options.facebook ) { 92 if ( 'Custom' === options.facebook_event_name ) { 93 track_facebook( options.facebook_event_name_custom, 'trackCustom' ); 94 } else { 95 track_facebook( options.facebook_event_name, 'track' ); 96 } 97 } 98 } 99 100 function track_vkontakte( event_name ) { 101 if ( window.VK && typeof ( VK ) === 'object' ) { 102 VK.Retargeting.Event( event_name ); 103 } else { 104 window.console.log( 'Vkontakte not loaded' ); 105 } 106 } 107 108 function track_yandex_metrika( event_name, id ) { 109 if ( window.ym && typeof ( ym ) === 'function' ) { 110 ym( id, 'reachGoal', event_name ); 111 } else { 112 window.console.log( 'Yandex Metrika not loaded' ); 113 } 114 } 115 116 function track_gtag( category, action, label ) { 117 if ( window.gtag && typeof ( gtag ) === 'function' ) { 118 gtag( 119 'event', 120 action, 121 { 122 'event_category' : category, 123 'event_label' : label 124 } 125 ); 126 } else { 127 window.console.log( 'Global Google Tag (gtag.js) not loaded' ); 128 } 129 } 130 131 function track_adwords( id, label, currency, value ) { 132 if ( window.gtag && typeof ( gtag ) === 'function' ) { 133 gtag( 134 'event', 135 'conversion', 136 { 137 'send_to': id + '/' + label, 138 'value': value, 139 'currency': currency 140 } 141 ); 142 } else { 143 window.console.log( 'Global Google Tag (gtag.js) not loaded' ); 144 } 145 } 146 147 function track_analytics( category, action, label ) { 148 if ( window.ga && typeof ( ga ) === 'function' ) { 149 ga( 150 'send', 151 'event', 152 { 153 eventCategory: category, 154 eventAction: action, 155 eventLabel: label, 156 } 157 ); 158 } else { 159 window.console.log( 'Google Analytics (analytics.js) not loaded' ); 160 } 161 } 162 163 function track_facebook( event_name, type ) { 164 if ( window.fbq && typeof ( fbq ) === 'function' ) { 165 fbq( type, event_name ); 166 } else { 167 window.console.log( 'Yandex Metrika not loaded' ); 168 } 169 } 170 } 171 ); 172 } 173)( window.jQuery, window, document ); 174 175// eof.
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.