1"use strict"; 2 3function convGetPdpAddToCartSelector(productDetailAddtocartSelector) { 4 var base = 5 "button[class*='btn-buy-shop'],button[class*='single_add_to_cart_button'], button[class*='add_to_cart']"; 6 return productDetailAddtocartSelector ? base + productDetailAddtocartSelector : base; 7} 8 9function convDelegatedClickEvent(event, currentTarget) { 10 return { 11 currentTarget: currentTarget, 12 target: event.target, 13 preventDefault: function () { 14 event.preventDefault(); 15 }, 16 stopPropagation: function () { 17 event.stopPropagation(); 18 }, 19 }; 20} 21 22function convEnsureAtcDelegatedClickHandler() { 23 if (window.convAtcDelegated) { 24 return; 25 } 26 window.convAtcDelegated = true; 27 window.convAtcPdpContext = window.convAtcPdpContext || { 28 variations_data: {}, 29 product_detail_addtocart_selector: "", 30 }; 31 32 document.addEventListener("click", function (event) { 33 if (!event.target || !event.target.closest) { 34 return; 35 } 36 37 var ctx = window.convAtcPdpContext || {}; 38 var pdpSelector = convGetPdpAddToCartSelector( 39 ctx.product_detail_addtocart_selector || "" 40 ); 41 var pdpBtn = event.target.closest(pdpSelector); 42 var listLink = event.target.closest("a[href*='add-to-cart']"); 43 var handler = window.tvc_js; 44 45 if (!handler) { 46 return; 47 } 48 49 if ( 50 pdpBtn && 51 typeof handler.add_to_cart_click === "function" 52 ) { 53 handler.add_to_cart_click( 54 convDelegatedClickEvent(event, pdpBtn), 55 ctx.variations_data || {}, 56 "Product Pages" 57 ); 58 return; 59 } 60 61 if ( 62 listLink && 63 typeof handler.list_add_to_cart_click === "function" 64 ) { 65 handler.list_add_to_cart_click(convDelegatedClickEvent(event, listLink)); 66 } 67 }); 68} 69 70class TVC_GTM_WP_Enhanced { 71 /** 72 * Contact form 7 - formSubmit, Tracks form submissions for Contact Form 7 forms (excluding admin submissions). 73 * Pushes data to the dataLayer for analytics purposes. 74 * 75 * @param {Event} e The form submit event object. 76 */ 77 78 async run_ajax(data, callback) { 79 try { 80 const payload = {}; 81 for (const key in data) { 82 if (!Object.prototype.hasOwnProperty.call(data, key)) { 83 continue; 84 } 85 const val = data[key]; 86 payload[key] = 87 val !== null && typeof val === "object" 88 ? JSON.stringify(val) 89 : val; 90 } 91 const response = await fetch(this.options.tvc_ajax_url, { 92 method: "POST", 93 headers: { 94 "Content-Type": "application/x-www-form-urlencoded", 95 }, 96 body: new URLSearchParams(payload), 97 }); 98 const result = await response.json(); 99 if (callback) callback(result); 100 } catch (error) { 101 console.error("Conversios: AJAX error", error); 102 } 103 } 104 105 conv_form_lead_submit_capi(form_submit_datalayer) { 106 if (this.options.is_sst_trans === "") { 107 if ( 108 this.options.capiplans && 109 JSON.parse(this.options.capiplans).includes(parseInt(this.options.plan_id)) 110 ) { 111 //facebook api 112 var data = { 113 action: "facebook_converstion_api_wp", 114 nonce: ConvAioGlobal.nonce, 115 fb_event: "Lead", 116 event_id: this.options.fb_event_id, 117 custom_data: JSON.stringify(form_submit_datalayer), 118 }; 119 this.run_ajax(data, (response) => { 120 // console.log(response); 121 }); 122 } 123 } 124 } 125 126 sanitizePrice(varPrice) { 127 if (typeof varPrice !== "string") { 128 return parseFloat(varPrice) || 0; 129 } 130 /* Remove currency symbols and non-numeric chars except dot/comma */ 131 var cleanPrice = varPrice.replace(/[^0-9\.,]/g, ""); 132 if (cleanPrice.includes(".") && cleanPrice.includes(",")) { 133 if (cleanPrice.lastIndexOf(".") < cleanPrice.lastIndexOf(",")) { 134 // format: 1.250,50 (European) 135 cleanPrice = cleanPrice.replace(/\./g, "").replace(",", "."); 136 } else { 137 // format: 1,250.50 (US/UK) 138 cleanPrice = cleanPrice.replace(/,/g, ""); 139 } 140 } else if (cleanPrice.includes(",")) { 141 // format: 1250,50 (European, no thousands separator) 142 cleanPrice = cleanPrice.replace(",", "."); 143 } 144 return parseFloat(cleanPrice) || 0; 145 } 146 147 formsubmit_cf7_tracking(e) { 148 if (this.options.is_admin == true) { 149 return; 150 } 151 152 var form_submit_datalayer = { 153 event: "form_lead_submit", 154 cov_form_name: e.target.ariaLabel, 155 cov_form_type: "CF7 Plugin", 156 cov_form_id: e.detail.contactFormId, 157 }; 158 159 dataLayer.push(form_submit_datalayer); 160 this.conv_form_lead_submit_capi(form_submit_datalayer); 161 } 162 163 /** 164 * Ninja form - formSubmit, Handles form submission for Ninja Forms with dataLayer push. 165 * 166 * This function is triggered when a Ninja Form is submitted. It checks if the user is in the admin area, and if not, it pushes form submission data to the dataLayer for tracking purposes. 167 * 168 * @param {Event} e The DOM event object for the form submission. 169 * @param {Object} r The response object from the Ninja Forms submission. 170 * @param {number} id The ID of the submitted Ninja Form. 171 * @returns {void} 172 */ 173 formsubmit_ninja_tracking(e, r, id) { 174 if (this.options.is_admin == true) { 175 return; 176 } 177 var title = e.target.ariaLabel 178 ? e.target.ariaLabel 179 : r.response.data.settings.title; 180 var form_submit_datalayer = { 181 event: "form_lead_submit", 182 cov_form_name: title, 183 cov_form_type: "Ninja Form Plugin", 184 cov_form_id: r.id, 185 }; 186 187 dataLayer.push(form_submit_datalayer); 188 this.conv_form_lead_submit_capi(form_submit_datalayer); 189 } 190 191 /** 192 * WpForm & Formidable - FormSubmit, Submits a form using AJAX and pushes data to the dataLayer. 193 * 194 * @param {any[]} data The data to be pushed to the dataLayer. 195 * @param {string} is_plugin (optional) A flag indicating if this call originates from a plugin. Defaults to an empty string. 196 */ 197 formsubmit_ajax_tracking(fdata = [], is_plugin = "") { 198 var postdata = { 199 action: "datalayer_push", 200 nonce: ConvAioGlobal.nonce, 201 is_plugin: is_plugin, 202 }; 203 204 if (typeof fdata === "string") { 205 const parts = fdata.split("&"); 206 const params = {}; 207 for (let i = 0; i < parts.length; i++) {
208 const keyVal = parts[i].split("="); 209 params[decodeURIComponent(keyVal[0])] = decodeURIComponent( 210 keyVal[1] || "" 211 ); 212 } 213 214 // Formidable plugin related 215 if ("action" in params && params.action == "frm_entries_create") { 216 postdata["form_id"] = params.form_id; 217 postdata["form_action"] = params.action; 218 } 219 } else { 220 // WpForm plugin related 221 if ("action" in fdata && fdata["action"] == "wpforms_submit") { 222 postdata["form_id"] = fdata["form_id"]; 223 postdata["form_action"] = fdata["action"]; 224 } 225 } 226 227 this.run_ajax(postdata, (datalayer) => { 228 window.dataLayer = window.dataLayer || []; 229 dataLayer.push(datalayer); 230 }); 231 } 232} // End Class::TVC_GTM_WP_Enhanced 233 234class TVC_GTM_Enhanced extends TVC_GTM_WP_Enhanced { 235 constructor(options = {}) { 236 super(); 237 this.options = { 238 tracking_option: "UA", 239 }; 240 if (options) { 241 Object.assign(this.options, options); 242 } 243 //console.log(this.options); 244 //this.addEventBindings(); 245 } 246 singleProductaddToCartEventBindings( 247 variations_data, 248 product_detail_addtocart_selector 249 ) { 250 window.convAtcPdpContext = { 251 variations_data: variations_data || {}, 252 product_detail_addtocart_selector: product_detail_addtocart_selector || "", 253 }; 254 convEnsureAtcDelegatedClickHandler(); 255 } 256 ListProductaddToCartEventBindings() { 257 convEnsureAtcDelegatedClickHandler(); 258 } 259 ListProductSelectItemEventBindings() { 260 var elements = ""; 261 elements = document.querySelectorAll( 262 "li.product a:not([href*=add-to-cart],.product_type_variable, .product_type_grouped" 263 ); 264 if (elements.length > 0) { 265 for (var i = 0; i < elements.length; i++) { 266 if (elements[i]) { 267 elements[i].addEventListener("click", (event) => 268 this.list_select_item_click(event) 269 ); 270 } 271 } 272 } 273 } 274 RemoveItemCartEventBindings() { 275 var elements = ""; 276 elements = document.querySelectorAll('a[href*="?remove_item"]'); 277 if (elements.length > 0) { 278 for (var i = 0; i < elements.length; i++) { 279 if (elements[i]) { 280 elements[i].addEventListener("click", (event) => this.remove_item_click(event)); 281 } 282 } 283 } 284 } 285 /* 286 * check remarketing option 287 */ 288 is_add_remarketing_tags() { 289 if ( 290 this.options.is_admin == false && 291 this.options.ads_tracking_id != "" && 292 (this.options.remarketing_tags == 1 || 293 this.options.dynamic_remarketing_tags == 1) 294 ) { 295 return true; 296 } else { 297 return false; 298 } 299 } 300 301 get_variation_data_by_id(variations_data, variation_id) { 302 //console.log(variations_data.available_variations) 303 var r_val = ""; 304 if (variations_data.available_variations.length > 0) { 305 variations_data.available_variations.forEach((element, index) => { 306 if (element.variation_id == variation_id) { 307 r_val = element; 308 } 309 }); 310 return r_val; 311 //console.log(variations_data.available_variations) 312 } 313 } 314 get_variation_attribute_name(p_attributes) { 315 //console.log(p_attributes); 316 var p_v_title = ""; 317 if (Object.keys(p_attributes).length > 0) { 318 for (var index in p_attributes) { 319 p_v_title += 320 p_v_title == "" ? p_attributes[index] : " | " + p_attributes[index]; 321 } 322 return p_v_title; 323 } 324 } 325 get_event_data_layer(event_name) { 326 if (event_name != "") { 327 if (Object.keys(dataLayer).length > 0) { 328 for (var dataLayer_item in dataLayer) { 329 var event = dataLayer[dataLayer_item].event; 330 if (event_name == event) { 331 return dataLayer[dataLayer_item]; 332 } 333 } 334 } 335 } 336 } 337 get_product_from_product_list(product_id) { 338 if (product_id != "") { 339 if (Object.keys(conProductList).length > 0) { 340 for (var dataLayer_item in conProductList[0]) { 341 if (conProductList[0][dataLayer_item].hasOwnProperty("id")) { 342 var id = conProductList[0][dataLayer_item].id; 343 if (product_id == id) { 344 return conProductList[0][dataLayer_item]; 345 } 346 } 347 } 348 } 349 } 350 } 351 get_product_from_product_list_by_url(prod_obj, key, product_url) { 352 if (product_url != "") { 353 if (Object.keys(prod_obj).length > 0) { 354 for (var dataLayer_item in prod_obj[0]) { 355 if (prod_obj[0][dataLayer_item].hasOwnProperty(key)) { 356 var map_val = prod_obj[0][dataLayer_item][key]; 357 if (product_url == map_val) { 358 return prod_obj[0][dataLayer_item]; 359 } 360 } 361 } 362 } 363 } 364 } 365 list_select_item_click(event) { 366 var this_var = event.currentTarget; 367 var href = this_var.getAttribute("href"); 368 var item = this.get_product_from_product_list_by_url( 369 conProductList, 370 "productlink", 371 href 372 ); 373 var add_to_cart_datalayer = { 374 event: "select_item", 375 ecommerce: { 376 items: [ 377 { 378 affiliation: this.options.affiliation, 379 item_id: item.id, 380 item_name: item.name, 381 currency: this.options.currency, 382 item_category: item.category, 383 price: this.sanitizePrice(item.price), 384 quantity: 1, 385 }, 386 ], 387 }, 388 }; 389 dataLayer.push(add_to_cart_datalayer); 390 } 391 remove_item_click(event) { 392 var this_var = event.currentTarget; 393 var href = this_var.getAttribute("href"); 394 if (href) { 395 var item = this.get_product_from_product_list_by_url( 396 conCarttList, 397 "remove_cart_link", 398 href 399 ); 400 401 var itemPrice = this.sanitizePrice(item.price); 402 var ecomval = (itemPrice * item.quantity).toFixed(2); 403 404 var add_to_cart_datalayer = { 405 event: "remove_from_cart", 406 ecommerce: { 407 currency: this.options.currency, 408 value: parseFloat(ecomval), 409 items: [ 410 { 411 affiliation: this.options.affiliation, 412 item_id: item.id, 413 item_name: item.name, 414 currency: this.options.currency, 415 item_category: item.category, 416 price: itemPrice, 417 quantity: item.quantity, 418 }, 419 ], 420 }, 421 }; 422 dataLayer.push(add_to_cart_datalayer); 423 } 424 } 425 list_add_to_cart_click(event) { 426 // console.log(this.options); 427 var this_var = event.currentTarget; 428 var href = this_var.getAttribute("href"); 429 var product_id = this.getParameterByName("add-to-cart", href); 430 var item = this.get_product_from_product_list(product_id); 431 var quantity = 1; 432 if (this_var.getAttribute("data-quantity")) { 433 quantity = this_var.getAttribute("data-quantity"); 434 } 435 var itemPrice = this.sanitizePrice(item.price); 436 var add_to_cart_datalayer = { 437 event: "add_to_cart", 438 ecommerce: { 439 currency: this.options.currency, 440 value: itemPrice, 441 items: [ 442 { 443 affiliation: this.options.affiliation, 444 item_id: item.id, 445 item_name: item.name, 446 currency: this.options.currency, 447 item_category: item.category, 448 price: itemPrice, 449 quantity: parseInt(quantity), 450 }, 451 ], 452 }, 453 }; 454 455 if ( 456 this.options.fb_pixel_id != undefined && 457 this.options.fb_pixel_id != null && 458 this.options.fb_pixel_id != "" 459 ) { 460 add_to_cart_datalayer.fb_event_id = 461 this.options.fb_event_id + "p" + item.id; 462 } 463 464 if ( 465 this.options.snapchat_ads_pixel_id != undefined && 466 this.options.snapchat_ads_pixel_id != null && 467 this.options.snapchat_ads_pixel_id != "" 468 ) { 469 add_to_cart_datalayer.snapchat_event_id = 470 this.options.snapchat_event_id + "p" + item.id; 471 } 472 473 if ( 474 this.options.tiKtok_ads_pixel_id != undefined && 475 this.options.tiKtok_ads_pixel_id != null && 476 this.options.tiKtok_ads_pixel_id != "" 477 ) { 478 add_to_cart_datalayer.tiktok_event_id = 479 this.options.tiktok_event_id + "p" + item.id; 480 } 481 482 dataLayer.push(add_to_cart_datalayer); 483 if (this.options.is_sst_trans == "") { 484 if ( 485 this.options.capiplans && 486 JSON.parse(this.options.capiplans).includes(parseInt(this.options.plan_id)) 487 ) { 488 //facebook api 489 var data = { 490 action: "facebook_converstion_api", 491 nonce: ConvAioGlobal.nonce, 492 fb_event: "AddToCart", 493 fb_ecurrent_url: window.location.href, 494 event_id: this.options.fb_event_id + "p" + item.id, 495 prodct_data: [item], 496 }; 497 this.run_ajax(data, (response) => { 498 // console.log(response); 499 }); 500 } 501 502 if ( 503 this.options.snapchat_access_token != undefined && 504 this.options.snapchat_access_token != null && 505 this.options.snapchat_access_token != "" 506 ) { 507 var snapchatEventConversionApiData = { 508 event_type: "ADD_CART", 509 event_id: this.options.snapchat_event_id + "p" + item.id, 510 prodct_data: item, 511 quantity: parseInt(quantity) || 1, 512 }; 513 } 514 515 if ( 516 this.options.tiktok_access_token != undefined && 517 this.options.tiktok_access_token != null && 518 this.options.tiktok_access_token != "" 519 ) { 520 var tiktokEventApiConversionData = { 521 event_type: "AddToCart", 522 event_id: this.options.tiktok_event_id + "p" + item.id, 523 prodct_data: item, 524 quantity: parseInt(quantity) || 1, 525 }; 526 } 527 528 let postData = { 529 snapchatEventConversionApiData: snapchatEventConversionApiData, 530 tiktokEventApiConversionData: tiktokEventApiConversionData,
531 action: "stf_converstion_api", 532 nonce: ConvAioGlobal.nonce, 533 }; 534 535 if ( 536 (this.options.snapchat_access_token != undefined && 537 this.options.snapchat_access_token != null && 538 this.options.snapchat_access_token != "") || 539 (this.options.tiktok_access_token != undefined && 540 this.options.tiktok_access_token != null && 541 this.options.tiktok_access_token != "") 542 ) { 543 this.run_ajax(postData, (response) => { 544 // console.log(response); 545 }); 546 } 547 } 548 } 549 getParameterByName(name, url = window.location.href) { 550 name = name.replace(/[\[\]]/g, "\\$&"); 551 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), 552 results = regex.exec(url); 553 if (!results) return null; 554 if (!results[2]) return ""; 555 return decodeURIComponent(results[2].replace(/\+/g, " ")); 556 } 557 /* 558 * below code run while add to cart on product page. 559 * ( Event=> add_to_cart) 560 */ 561 add_to_cart_click(event, variations_data, page_type = "Product Pages") { 562 var this_var = event.currentTarget; 563 var item_dataLayer = this.get_event_data_layer("view_item"); 564 if (this.options.is_admin == true) { 565 return; 566 } 567 if (item_dataLayer && item_dataLayer.ecommerce && item_dataLayer.ecommerce.items && item_dataLayer.ecommerce.items[0] && Object.keys(item_dataLayer.ecommerce.items[0]).length > 0) { 568 var item = item_dataLayer.ecommerce.items[0]; 569 var variation_attribute_name = ""; 570 var vari_data = ""; 571 /* Scope variation_id search to the closest form or container to prevent cross-product contamination */ 572 var form_container = this_var.closest("form, .product, .cart"); 573 var variation_input = form_container ? form_container.querySelector("input[name='variation_id']") : null; 574 var variation_id = ""; 575 if (variation_input && variation_input.value) { 576 variation_id = variation_input.value; 577 } 578 579 /* Fallback to global search if not found in scope, or check classic class-based element */ 580 if (!variation_id) { 581 var global_variation_input = document.querySelector("input[name='variation_id']"); 582 variation_id = global_variation_input ? global_variation_input.value : ""; 583 584 if (!variation_id) { 585 var variation_id_obj = document.getElementsByClassName("variation_id"); 586 if (variation_id_obj.length > 0) { 587 variation_id = variation_id_obj[0].value; 588 } 589 } 590 } 591 592 var varPrice = item.price; 593 if (variation_id != "" && variation_id != 0 && variation_id != "0" && variation_id != undefined) { 594 vari_data = this.get_variation_data_by_id( 595 variations_data, 596 variation_id 597 ); 598 if (vari_data) { 599 var p_attributes = vari_data.attributes; 600 if (Object.keys(p_attributes).length > 0) { 601 variation_attribute_name = 602 this.get_variation_attribute_name(p_attributes); 603 } 604 if (vari_data.display_price) { 605 varPrice = vari_data.display_price; 606 } else if (vari_data.display_regular_price) { 607 varPrice = vari_data.display_regular_price; 608 } 609 } 610 } 611 612 /* Robust quantity selector: check closest form first, then parent, then global fallback */ 613 var qty_input = null; 614 var cart_form = this_var.closest("form.cart"); 615 if (cart_form) { 616 qty_input = cart_form.querySelector("input[name=quantity]"); 617 } 618 if (!qty_input) { 619 qty_input = this_var.parentElement.querySelector("input[name=quantity]"); 620 } 621 var ecomqty = qty_input ? parseInt(qty_input.value) || 1 : 1; 622 623 varPrice = this.sanitizePrice(varPrice); 624 625 var ecomval = (varPrice * ecomqty).toFixed(2) 626 var ecomprodid = variation_id && variation_id !== '' && variation_id != 0 && variation_id != "0" ? variation_id : item.item_id; 627 if (isNaN(ecomval) || parseFloat(ecomval) === 0) { 628 ecomval = this.sanitizePrice(item.price); 629 } 630 631 632 var add_to_cart_datalayer = { 633 event: "add_to_cart", 634 ecommerce: { 635 currency: this.options.currency, 636 value: parseFloat(ecomval), 637 items: [ 638 { 639 affiliation: item.affiliation, 640 item_id: ecomprodid, 641 item_name: item.item_name, 642 currency: item.currency, 643 item_category: item.item_category, 644 price: varPrice, 645 quantity: ecomqty, 646 item_variant: variation_attribute_name, 647 }, 648 ], 649 }, 650 }; 651 652 if ( 653 this.options.fb_pixel_id != undefined && 654 this.options.fb_pixel_id != null && 655 this.options.fb_pixel_id != "" 656 ) { 657 add_to_cart_datalayer.fb_event_id = 658 this.options.fb_event_id + "p" + ecomprodid; 659 } 660 661 if ( 662 this.options.snapchat_ads_pixel_id != undefined && 663 this.options.snapchat_ads_pixel_id != null && 664 this.options.snapchat_ads_pixel_id != "" 665 ) { 666 add_to_cart_datalayer.snapchat_event_id = 667 this.options.snapchat_event_id + "p" + ecomprodid; 668 } 669 670 if ( 671 this.options.tiKtok_ads_pixel_id != undefined && 672 this.options.tiKtok_ads_pixel_id != null && 673 this.options.tiKtok_ads_pixel_id != "" 674 ) { 675 add_to_cart_datalayer.tiktok_event_id = 676 this.options.tiktok_event_id + "p" + ecomprodid; 677 } 678 dataLayer.push(add_to_cart_datalayer); 679 680 if (this.options.is_sst_trans == "") { 681 //facebook api 682 if ( 683 this.options.capiplans && 684 JSON.parse(this.options.capiplans).includes(parseInt(this.options.plan_id)) 685 ) { 686 var data = { 687 action: "facebook_converstion_api", 688 nonce: ConvAioGlobal.nonce, 689 fb_event: "AddToCart", 690 fb_ecurrent_url: window.location.href, 691 event_id: this.options.fb_event_id + "p" + ecomprodid, 692 prodct_data: [ 693 { id: ecomprodid, quantity: ecomqty, price: ecomval }, 694 ], 695 }; 696 this.run_ajax(data, (response) => { 697 // console.log(response); 698 }); 699 } 700 701 item.item_id = ecomprodid; 702 item.quantity = ecomqty; 703 if ( 704 this.options.capiplans && 705 JSON.parse(this.options.capiplans).includes(parseInt(this.options.plan_id)) 706 ) { 707 item.price = varPrice; 708 var snapchatEventConversionApiData = { 709 event_type: "ADD_CART", 710 event_id: this.options.snapchat_event_id, 711 prodct_data: item, 712 quantity: ecomqty, 713 }; 714 } 715 716 if ( 717 this.options.capiplans && 718 JSON.parse(this.options.capiplans).includes(parseInt(this.options.plan_id)) 719 ) { 720 item.price = varPrice; 721 var tiktokEventApiConversionData = { 722 event_type: "AddToCart", 723 event_id: this.options.tiktok_event_id, 724 prodct_data: item, 725 quantity: ecomqty, 726 }; 727 } 728 729 let postData = { 730 snapchatEventConversionApiData: snapchatEventConversionApiData, 731 tiktokEventApiConversionData: tiktokEventApiConversionData,
732 action: "stf_converstion_api", 733 nonce: ConvAioGlobal.nonce, 734 }; 735 if ( 736 (this.options.snapchat_access_token != undefined && 737 this.options.snapchat_access_token != null && 738 this.options.snapchat_access_token != "") || 739 (this.options.tiktok_access_token != undefined && 740 this.options.tiktok_access_token != null && 741 this.options.tiktok_access_token != "") 742 ) { 743 this.run_ajax(postData, (response) => { 744 // console.log(response); 745 }); 746 } 747 } 748 } 749 } 750 /* 751 * 752 */ 753 checkout_step_2_tracking() { 754 var item_dataLayer = this.get_event_data_layer("begin_checkout"); 755 var item_dataLayer_asi = this.get_event_data_layer("add_shipping_info"); 756 if (item_dataLayer_asi == undefined) { 757 if (this.options.is_admin == true) { 758 return; 759 } 760 if (item_dataLayer && item_dataLayer.ecommerce && item_dataLayer.ecommerce.items && item_dataLayer.ecommerce.items[0] && Object.keys(item_dataLayer.ecommerce.items[0]).length > 0) { 761 var checkout_step_2_datalayer = { 762 event: "add_shipping_info", 763 ecommerce: { 764 currency: this.options.currency, 765 value: item_dataLayer.ecommerce.value, 766 items: item_dataLayer.ecommerce.items, 767 }, 768 }; 769 dataLayer.push(checkout_step_2_datalayer); 770 } 771 } 772 } 773 checkout_step_3_tracking() { 774 var item_dataLayer = this.get_event_data_layer("begin_checkout"); 775 if (this.options.is_admin == true) { 776 return; 777 } 778 var fb_event_id_apay = this.options.fb_event_id; 779 if (item_dataLayer && item_dataLayer.ecommerce && item_dataLayer.ecommerce.items && item_dataLayer.ecommerce.items[0] && Object.keys(item_dataLayer.ecommerce.items[0]).length > 0) { 780 var checkout_step_3_datalayer = { 781 event: "add_payment_info", 782 fb_event_id: fb_event_id_apay, 783 ecommerce: { 784 currency: this.options.currency, 785 value: item_dataLayer.ecommerce.value, 786 items: item_dataLayer.ecommerce.items, 787 }, 788 }; 789 dataLayer.push(checkout_step_3_datalayer); 790 } 791 792 if (this.options.is_sst_trans == "") { 793 if (this.options.capiplans && JSON.parse(this.options.capiplans).includes(parseInt(this.options.plan_id))) { 794 //facebook api 795 var data = { 796 action: "facebook_converstion_api", 797 nonce: ConvAioGlobal.nonce, 798 fb_event: "AddPaymentInfo", 799 fb_ecurrent_url: window.location.href, 800 event_id: fb_event_id_apay, 801 cart_total: item_dataLayer.ecommerce.value, 802 prodct_data: item_dataLayer.ecommerce.items, 803 }; 804 this.run_ajax(data, (response) => { 805 // console.log(response); 806 }); 807 } 808 } 809 } 810 811 getCurrentTime() { 812 if (!Date.now) { 813 return new Date().getTime(); 814 } else { 815 //Math.floor(Date.now() / 1000) 816 return Date.now(); 817 } 818 } 819 getClientId() { 820 let client_id = this.getCookie("_ga"); 821 if (client_id != null && client_id != "") { 822 return client_id; 823 } else { 824 return; 825 } 826 } 827 setCookie(name, value, days) { 828 var expires = ""; 829 if (days) { 830 var date = new Date(); 831 date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); 832 expires = "; expires=" + date.toUTCString(); 833 } 834 document.cookie = name + "=" + (value || "") + expires + "; path=/"; 835 } 836 getCookie(name) { 837 var nameEQ = name + "="; 838 var ca = document.cookie.split(";"); 839 for (var i = 0; i < ca.length; i++) { 840 var c = ca[i]; 841 while (c.charAt(0) == " ") c = c.substring(1, c.length); 842 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); 843 } 844 return null; 845 } 846 eraseCookie(name) { 847 document.cookie = 848 name + "=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;"; 849 } 850}
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.