1/* 2 * 3 * Dynamic Ads + Pixel for TikTok 4 * 5 * @author BusinessTech.fr 6 * @copyright Business Tech 7 * 8 * ____ _______ 9 * | _ \ |__ __| 10 * | |_) | | | 11 * | _ < | | 12 * | |_) | | | 13 * |____/ |_| 14 * 15 */ 16 17if (btTkpPixel.bUseConsent == true) { 18 // Default value 19 ttq.disableCookie(); 20 21 // Use the consent level from ACB 22 if (btTkpPixel.iConsentConsentLvl == 0) { 23 ttq.disableCookie(); 24 } else if (btTkpPixel.iConsentConsentLvl == 1) { 25 ttq.disableCookie(); 26 } else if (btTkpPixel.iConsentConsentLvl == 2) { 27 ttq.enableCookie(); 28 } else if (btTkpPixel.iConsentConsentLvl == 3) { 29 ttq.enableCookie(); 30 } 31 32 if (btTkpPixel.bConsentHtmlElement != "") { 33 $(btTkpPixel.bConsentHtmlElement).bind("click", function (event) { 34 $.ajax({ 35 type: "POST", 36 url: btTkpPixel.ajaxUrl, 37 dataType: "json", 38 data: { 39 ajax: 1, 40 action: "updateConsent", 41 token: btTkpPixel.token, 42 }, 43 success: function (jsonData, textStatus, jqXHR) { 44 ttq.enableCookie(); 45 }, 46 }); 47 }); 48 } else { 49 ttq.enableCookie(); 50 } 51} else { 52 ttq.enableCookie(); 53} 54 55if (btTkpPixel.useAdvancedMatcing && btTkpPixel.userEmail) { 56 ttq.identify({ 57 email: btTkpPixel.userEmail, 58 }); 59} 60 61$(document).ready(function () { 62 63 if (typeof prestashop !== 'undefined') { 64 prestashop.on( 65 'updateCart', 66 function (event) { 67 if (event && event.reason && event.reason.linkAction == "add-to-cart") { 68 // Clean bad quote for the building addToCart and prevent mismatch with tiktok services 69 let content_name_clean = btTkpPixel.tagContent.content_name.value; 70 content_name_clean = content_name_clean.replace('\'', ''); 71 content_name_clean = content_name_clean.replace('\'', ''); 72 73 let content_category_clean = btTkpPixel.tagContent.content_category.value; 74 content_category_clean = content_category_clean.replace('\'', ''); 75 content_category_clean = content_category_clean.replace('\'', ''); 76 77 let content_ids_clean = btTkpPixel.tagContent.content_id.value; 78 content_ids_clean = content_ids_clean.replace('\'', ''); 79 content_ids_clean = content_ids_clean.replace('\'', ''); 80 81 let content_currency_clean = btTkpPixel.tagContent.currency.value; 82 content_currency_clean = content_currency_clean.replace('\'', ''); 83 content_currency_clean = content_currency_clean.replace('\'', ''); 84 85 let product_price_value = btTkpPixel.tagContent.value.value; 86 event.reason.cart.products.forEach( function(product, index, array) { 87 if(product.id_product == event.resp.idProduct && product.id_product_attribute == event.resp.idProductAttribute){ 88 product_price_value = product.price_with_reduction; 89 } 90 }); 91 92 ttq.track("AddToCart", { 93 content_name: content_name_clean, 94 content_category: content_category_clean, 95 content_id: event.resp.id_product + btTkpPixel.tkpSeparator + event.resp.id_product_attribute, 96 value: product_price_value, 97 currency: content_currency_clean, 98 }); 99 } 100 } 101 ); 102 103 // Handle case for combination update 104 prestashop.on( 105 'updatedProduct', 106 function (event) { 107 if (event) { 108 $.ajax({
109 type: "POST", 110 url: btTkpPixel.ajaxUrl, 111 dataType: "json", 112 data: { 113 ajax: 1, 114 action: "updateCombination", 115 id_product_attribute: event.id_product_attribute, 116 id_product: $('input[name="id_product"').val(), 117 token: btTkpPixel.token, 118 }, 119 success: function (jsonData, textStatus, jqXHR) { 120 ttq.track("ViewContent", { 121 content_type: 'product', 122 content_id: jsonData.content_id, 123 value: jsonData.value, 124 currency: jsonData.currency, 125 content_name: jsonData.content_name, 126 content_category: jsonData.content_category, 127 }); 128 }, 129 }); 130 } 131 } 132 ) 133 } 134 135 $(btTkpPixel.btnOrder).bind("click", function () { 136 ttq.track("StartCheckout"); 137 }); 138 139 $(btTkpPixel.elementCategoryWishlist).bind("click", function () { 140 ttq.track("AddToWishlist"); 141 }); 142 143 $(btTkpPixel.elementProductWishlist).bind("click", function () { 144 ttq.track("AddToWishlist"); 145 }); 146 147 $(btTkpPixel.elementCategoryProduct).each(function (index) { 148 $(this).bind("click", function (event) { 149 $.ajax({
150 type: "POST", 151 url: btTkpPixel.ajaxUrl, 152 dataType: "json", 153 data: { 154 ajax: 1, 155 action: "selectItem", 156 iProductId: $(this).attr("data-id-product"), 157 token: btTkpPixel.token, 158 }, 159 success: function (jsonData, textStatus, jqXHR) { 160 ttq.track("AddToCart", { 161 content_name: jsonData.content_name, 162 content_category: jsonData.content_category, 163 content_id: jsonData.content_id, 164 value: jsonData.value, 165 currency: jsonData.currency, 166 }); 167 }, 168 }); 169 }); 170 }); 171});
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.