1function checkCounters(name) { 2 if (typeof name !== "undefined") { 3 if ( 4 name == "google" && 5 arAsproOptions['COUNTERS']["GOOGLE_ECOMERCE"] == "Y" && 6 arAsproOptions['COUNTERS']["GOOGLE_COUNTER"] > 0 7 ) { 8 return true; 9 } else if ( 10 name == "yandex" && 11 arAsproOptions['COUNTERS']["YANDEX_ECOMERCE"] == "Y" && 12 arAsproOptions['COUNTERS']["YANDEX_COUNTER"] > 0 13 ) { 14 return true; 15 } else { 16 return false; 17 } 18 } else if ( 19 (arAsproOptions['COUNTERS']["YANDEX_ECOMERCE"] == "Y" && arAsproOptions['COUNTERS']["YANDEX_COUNTER"] > 0) || 20 (arAsproOptions['COUNTERS']["GOOGLE_ECOMERCE"] == "Y" && arAsproOptions['COUNTERS']["GOOGLE_COUNTER"] > 0) 21 ) { 22 return true; 23 } else { 24 return false; 25 } 26} 27 28function waitLayer(delay, callback) { 29 if (typeof dataLayer !== "undefined" && typeof callback === "function") { 30 callback(); 31 } else { 32 setTimeout(function () { 33 waitLayer(delay, callback); 34 }, delay); 35 } 36} 37 38function addBasketCounter(id, callback) { 39 if (checkCounters()) { 40 $.ajax({ 41 url: arAsproOptions["SITE_DIR"] + "ajax/goals.php", 42 dataType: "json", 43 type: "POST", 44 data: { ID: id }, 45 success: function (item) { 46 if (!!item && !!item.ID) { 47 _tmr.push({ 48 type: 'reachGoal', 49 id: 3667557, 50 value: parseFloat(item.PRICE), 51 goal: 'goal_basket_add', 52 params: { product_id: item.ID } 53 }); 54 55 let ecommerce = { 56 items: [ 57 { 58 item_name: item.NAME, // Name or ID is required. 59 item_id: item.ID, 60 price: parseFloat(item.PRICE), 61 item_brand: item.BRAND, 62 item_category: item.CATEGORY, 63 item_list_name: "List Results", 64 item_list_id: item.IBLOCK_SECTION_ID, 65 affiliation: item.SHOP_NAME, 66 index: 1, 67 quantity: parseFloat(item.QUANTITY), 68 }, 69 ], 70 }; 71 if (arAsproOptions['COUNTERS']["GA_VERSION"] === "v3") { 72 ecommerce = { 73 currencyCode: item.CURRENCY, 74 add: { 75 products: [ 76 { 77 id: item.ID, 78 name: item.NAME, 79 price: parseFloat(item.PRICE), 80 brand: item.BRAND, 81 category: item.CATEGORY, 82 quantity: parseFloat(item.QUANTITY), 83 }, 84 ], 85 }, 86 }; 87 } 88 waitLayer(100, function () { 89 dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. 90 dataLayer.push({ 91 // event: 'add_to_cart', 92 event: arAsproOptions['COUNTERS']["GOOGLE_EVENTS"]["ADD2BASKET"], 93 currency: item.CURRENCY, 94 value: parseFloat(item.PRICE), 95 ecommerce: ecommerce, 96 }); 97 if (typeof callback == "function") { 98 callback(); 99 } 100 }); 101 } 102 }, 103 }); 104 } 105} 106 107function delFromBasketCounter(id, callback) { 108 if (checkCounters()) { 109 $.ajax({ 110 url: arAsproOptions["SITE_DIR"] + "ajax/goals.php", 111 dataType: "json", 112 type: "POST", 113 data: { ID: id }, 114 success: function (item) { 115 if (item.ID) { 116 let ecommerce = { 117 items: [ 118 { 119 item_name: item.NAME, // Name or ID is required. 120 item_id: item.ID, 121 price: parseFloat(item.PRICE), 122 item_brand: item.BRAND, 123 item_category: item.CATEGORY, 124 affiliation: item.SHOP_NAME, 125 item_list_name: "List Results", 126 }, 127 ], 128 }; 129 if (arAsproOptions['COUNTERS']["GA_VERSION"] === "v3") { 130 ecommerce = { 131 remove: { 132 products: [ 133 { 134 id: item.ID, 135 name: item.NAME, 136 category: item.CATEGORY, 137 }, 138 ], 139 }, 140 }; 141 } 142 waitLayer(100, function () { 143 dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. 144 dataLayer.push({ 145 event: arAsproOptions['COUNTERS']["GOOGLE_EVENTS"]["REMOVE_BASKET"], 146 currency: item.CURRENCY, 147 value: parseFloat(item.PRICE), 148 ecommerce: ecommerce, 149 }); 150 if (typeof callback == "function") { 151 callback(); 152 } 153 }); 154 } 155 }, 156 }); 157 } 158} 159 160function viewItemCounter(id, price_id) { 161 if (checkCounters()) { 162 $.ajax({ 163 url: arAsproOptions["SITE_DIR"] + "ajax/goals.php", 164 dataType: "json", 165 type: "POST", 166 data: { PRODUCT_ID: id, PRICE_ID: price_id }, 167 success: function (item) { 168 if (item.ID) { 169 let ecommerce = { 170 items: [ 171 { 172 item_name: item.NAME, // Name or ID is required. 173 item_id: item.ID, 174 price: parseFloat(item.PRICE), 175 item_brand: item.BRAND, 176 item_category: item.CATEGORY, 177 item_list_name: "List Results", 178 item_list_id: item.IBLOCK_SECTION_ID, 179 affiliation: item.SHOP_NAME, 180 index: 1, 181 quantity: parseFloat(item.QUANTITY), 182 }, 183 ], 184 }; 185 if (arAsproOptions['COUNTERS']["GA_VERSION"] === "v3") { 186 ecommerce = { 187 detail: { 188 products: [ 189 { 190 id: item.ID, 191 name: item.NAME, 192 price: parseFloat(item.PRICE), 193 brand: item.BRAND, 194 category: item.CATEGORY, 195 }, 196 ], 197 }, 198 }; 199 } 200 waitLayer(100, function () { 201 dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. 202 dataLayer.push({ 203 event: "view_item", 204 currency: item.CURRENCY, 205 value: parseFloat(item.PRICE), 206 ecommerce: ecommerce, 207 }); 208 }); 209 } 210 }, 211 }); 212 } 213} 214 215function purchaseCounter(order_id, type, callback) { 216 if (checkCounters()) { 217 $.ajax({ 218 url: arAsproOptions["SITE_DIR"] + "ajax/goals.php", 219 dataType: "json", 220 type: "POST", 221 data: { ORDER_ID: order_id, TYPE: type }, 222 success: function (order) { 223 var products = []; 224 const items = []; 225 if (order.ITEMS) { 226 for (var i in order.ITEMS) { 227 products.push({ 228 id: order.ITEMS[i].ID, 229 sku: order.ITEMS[i].ID, 230 name: order.ITEMS[i].NAME, 231 price: order.ITEMS[i].PRICE, 232 brand: order.ITEMS[i].BRAND, 233 category: order.ITEMS[i].CATEGORY, 234 quantity: order.ITEMS[i].QUANTITY, 235 }); 236 items.push({ 237 item_id: order.ITEMS[i].ID, 238 item_name: order.ITEMS[i].NAME, 239 price: parseFloat(order.ITEMS[i].PRICE), 240 item_brand: order.ITEMS[i].BRAND, 241 item_category: order.ITEMS[i].CATEGORY, 242 affiliation: order.SHOP_NAME, 243 quantity: parseFloat(order.ITEMS[i].QUANTITY), 244 }); 245 } 246 } 247 if (order.ID) { 248 let ecommerce = { 249 transaction_id: order.ACCOUNT_NUMBER, 250 affiliation: order.SHOP_NAME, 251 value: order.PRICE, 252 tax: order.TAX_VALUE, 253 shipping: order.PRICE_DELIVERY, 254 currency: order.CURRENCY, 255 items: items, 256 }; 257 if (arAsproOptions['COUNTERS']["GA_VERSION"] === "v3") { 258 ecommerce = { 259 purchase: { 260 actionField: { 261 id: order.ACCOUNT_NUMBER, 262 shipping: order.PRICE_DELIVERY, 263 tax: order.TAX_VALUE, 264 list: type, 265 revenue: order.PRICE, 266 }, 267 products: products, 268 }, 269 }; 270 } 271 waitLayer(100, function () { 272 dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. 273 dataLayer.push({ 274 event: arAsproOptions['COUNTERS']["GOOGLE_EVENTS"]["PURCHASE"], 275 ecommerce: ecommerce, 276 }); 277 278 if (typeof callback !== "undefined") { 279 callback(ecommerce); 280 } 281 }); 282 } else { 283 if (typeof callback !== "undefined") { 284 callback(); 285 } 286 } 287 }, 288 error: function () { 289 if (typeof callback !== "undefined") { 290 callback(); 291 } 292 }, 293 }); 294 } 295} 296 297function checkoutCounter(step, option, callback) { 298 if (checkCounters("google")) { 299 $.ajax({ 300 url: arAsproOptions["SITE_DIR"] + "ajax/goals.php", 301 dataType: "json", 302 type: "POST", 303 data: { BASKET: "Y" }, 304 success: function (basket) { 305 var products = []; 306 const items = []; 307 let summ = 0; 308 let currency = "RUB"; 309 if (basket.ITEMS) { 310 for (var i in basket.ITEMS) { 311 products.push({ 312 id: basket.ITEMS[i].ID, 313 name: basket.ITEMS[i].NAME, 314 price: basket.ITEMS[i].PRICE, 315 brand: basket.ITEMS[i].BRAND, 316 category: basket.ITEMS[i].CATEGORY, 317 quantity: basket.ITEMS[i].QUANTITY, 318 }); 319 items.push({ 320 item_id: basket.ITEMS[i].ID, 321 item_name: basket.ITEMS[i].NAME, 322 price: parseFloat(basket.ITEMS[i].PRICE), 323 item_brand: basket.ITEMS[i].BRAND, 324 item_category: basket.ITEMS[i].CATEGORY, 325 affiliation: basket.SHOP_NAME, 326 quantity: parseFloat(basket.ITEMS[i].QUANTITY), 327 }); 328 summ += basket.ITEMS[i].PRICE; 329 currency = basket.ITEMS[i].CURRENCY; 330 } 331 } 332 if (products) { 333 let ecommerce = { 334 items: items, 335 }; 336 if (arAsproOptions['COUNTERS']["GA_VERSION"] === "v3") { 337 ecommerce = { 338 checkout: { 339 actionField: { 340 step: step, 341 option: option, 342 }, 343 products: products, 344 }, 345 }; 346 } 347 waitLayer(100, function () { 348 dataLayer.push({ ecommerce: null }); // Clear the previous ecommerce object. 349 dataLayer.push({ 350 event: arAsproOptions['COUNTERS']["GOOGLE_EVENTS"]["CHECKOUT_ORDER"], 351 currency: currency, 352 value: parseFloat(summ), 353 ecommerce: ecommerce, 354 /*"eventCallback": function() { 355 if((typeof callback !== 'undefined') && (typeof callback === 'function')){ 356 callback(); 357 } 358 }*/ 359 }); 360 if (typeof callback !== "undefined" && typeof callback === "function") { 361 callback(); 362 } 363 }); 364 } 365 }, 366 }); 367 } 368} 369 370function addFavoriteCounter(id, callback) { 371 if (checkCounters()) { 372 $.ajax({ 373 url: arAsproOptions["SITE_DIR"] + "ajax/goals.php", 374 dataType: "json", 375 type: "POST", 376 data: { ID: id }, 377 success: function (item) { 378 if (!!item && !!item.ID) { 379 console.log(123); 380 _tmr.push({ 381 type: 'reachGoal', 382 id: 3667557, 383 value: parseFloat(item.PRICE), 384 goal: 'goal_wish_add', 385 params: { product_id: item.ID } 386 }); 387 } 388 }, 389 }); 390 } 391} 392 393function addViewCardCounter(id, callback) { 394 if (checkCounters()) { 395 $.ajax({ 396 url: arAsproOptions["SITE_DIR"] + "ajax/goals.php", 397 dataType: "json", 398 type: "POST", 399 data: { PRODUCT_ID: id }, 400 success: function (item) { 401 if (!!item && !!item.ID) { 402 _tmr.push({ 403 type: 'reachGoal', 404 id: 3667557, 405 value: parseFloat(item.PRICE), 406 goal: 'view_card', 407 params: { product_id: item.ID } 408 }); 409 } 410 }, 411 }); 412 } 413} 414 415function addOrderSuccessCounter(id, callback) { 416 if (checkCounters()) { 417 $.ajax({ 418 url: arAsproOptions["SITE_DIR"] + "ajax/goals.php", 419 dataType: "json", 420 type: "POST", 421 data: { ORDER_ID: id }, 422 success: function (items) { 423 if(items.ITEMS){
424 Object.values(items.ITEMS).forEach(function(product){ 425 _tmr.push({ 426 type: 'reachGoal', 427 id: 3667557, 428 value: parseFloat(product.PRICE), // ÑиналÑÐ½Ð°Ñ Ñена Ñ ÑÑеÑом Ñкидки 429 goal: 'goal_order_success', 430 params: { product_id: product.PRODUCT_ID } 431 }); 432 }); 433 } 434 }, 435 }); 436 } 437} 438 439 440function waitCounter(idCounter, delay, callback) { 441 var obCounter = window['yaCounter' + idCounter]; 442 if (typeof obCounter === 'object') { 443 if (typeof callback === 'function') { 444 callback(); 445 } 446 } else { 447 setTimeout(function () { 448 waitCounter(idCounter, delay, callback); 449 }, delay); 450 } 451}; 452 453BX.addCustomEvent('onCounterGoals', function (eventdata) { 454 455 if (typeof eventdata !== 'object') { 456 eventdata = { 457 goal: 'undefined', 458 }; 459 } 460 console.log(eventdata.goal); 461 if (typeof eventdata.goal !== 'string') { 462 eventdata.goal = 'undefined'; 463 } 464 465 if (eventdata.goal === 'goal_basket_add') { 466 if ( 467 typeof eventdata.params === 'object' && 468 eventdata.params && 469 eventdata.params.id 470 ) { 471 addBasketCounter(eventdata.params.id); 472 } 473 } else if (eventdata.goal === 'goal_basket_remove') { 474 if ( 475 typeof eventdata.params === 'object' && 476 eventdata.params && 477 eventdata.params.id 478 ) { 479 delFromBasketCounter(eventdata.params.id); 480 } 481 } else if (eventdata.goal === 'goal_wish_add') { 482 if ( 483 typeof eventdata.params === 'object' && 484 eventdata.params && 485 eventdata.params.id 486 ) { 487 addFavoriteCounter(eventdata.params.id); 488 } 489 } else if (eventdata.goal === 'view_card') { 490 if ( 491 typeof eventdata.params === 'object' && 492 eventdata.params && 493 eventdata.params.id 494 ) { 495 addViewCardCounter(eventdata.params.id); 496 } 497 } else if (eventdata.goal === 'goal_order_begin') { 498 _tmr.push({ type: 'reachGoal', id: 3667557, goal: 'goal_order_begin'}); 499 } else if (eventdata.goal === 'goal_order_success') { 500 if ( 501 eventdata.result 502 ) { 503 addOrderSuccessCounter(eventdata.result); 504 } 505 } else if (eventdata.goal === 'reg') { 506 _tmr.push({ type: 'reachGoal', id: 3667557, goal: 'reg'}); 507 } 508 509 if ( 510 arAsproOptions['THEME']['YA_GOALS'] === 'Y' && 511 arAsproOptions['THEME']['YA_COUNTER_ID'] 512 ) { 513 var idCounter = arAsproOptions['THEME']['YA_COUNTER_ID']; 514 idCounter = parseInt(idCounter); 515 516 if (idCounter) { 517 try { 518 waitCounter(idCounter, 50, function () { 519 var obCounter = window['yaCounter' + idCounter]; 520 if (typeof obCounter === 'object') { 521 obCounter.reachGoal(eventdata.goal); 522 } 523 }); 524 } catch (e) { 525 console.error(e); 526 } 527 } else { 528 console.info('Bad counter id!', idCounter); 529 } 530 } 531}); 532 533readyDOM(function(){ 534 if (arAsproOptions['THEME']['USE_DEBUG_GOALS'] === 'Y') { 535 $.cookie('_ym_debug', '1'); 536 } else { 537 $.cookie('_ym_debug', null); 538 } 539});
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.