1$('document').ready(function () { 2 3 const $_wp_currency = $('html').attr('currencyIso4217'); 4 const $_wp_isActives = Base64.decode($('html').attr('getWeasyPixel')).split(','); 5 6 if (typeof weasyPixel== 'undefined') { 7 weasyPixel = function () { 8 return { 9 items: [], 10 header: {}, 11 itemsConv: [], 12 headerConv: {}, 13 currencyIso4217: $_wp_currency, 14 isActives: $_wp_isActives, 15 baseUrl: "/_inc/global_assets/builder/ajax/weasyPixel.php", 16 ipaddress: '127.0.0.1', 17 allowedFields: [ 18 'currency', 19 'value', 20 'content_category', 21 'search_string', 22 'delivery_category', 23 'num_items', 24 'order_id', 25 'content_name', 26 'content_type', 27 'content_ids', 28 'contents', 29 'fbclid' 30 ], 31 eventsByProvider: function () { 32 const providers = []; 33 providers['fbq'] = []; 34 providers['fbq']['event_PageView'] = 'PageView'; 35 providers['fbq']['event_PaymentInfo'] = 'AddPaymentInfo'; 36 providers['fbq']['event_ShippingInfo'] = 'AddShippingInfo'; // Custom 37 providers['fbq']['event_AddToCart'] = 'AddToCart'; 38 providers['fbq']['event_RemoveFromCart'] = 'RemoveFromCart'; // Custom 39 providers['fbq']['event_AddToWishList'] = 'AddToWishlist'; 40 providers['fbq']['event_CustomerRegister'] = 'CompleteRegistration'; 41 providers['fbq']['event_StartCheckout'] = 'InitiateCheckout'; 42 providers['fbq']['event_Purchase'] = 'Purchase'; 43 providers['fbq']['event_Search'] = 'Search'; 44 providers['fbq']['event_ViewProduct'] = 'ViewContent'; 45 providers['fbq']['event_ViewCart'] = 'ViewCart'; // Custom 46 providers['fbq']['event_ViewCartBudget'] = 'ViewCartBudget'; // Custom 47 providers['fbq']['event_Default'] = 'ViewContent'; 48 return providers; 49 }(), 50 getEvent: function (provider, event) { 51 if (weasyPixel.eventsByProvider.hasOwnProperty(provider)) { 52 if (weasyPixel.eventsByProvider[provider].hasOwnProperty(event)) { 53 return weasyPixel.eventsByProvider[provider][event]; 54 } else { 55 return weasyPixel.eventsByProvider[provider]['event_Default']; 56 } 57 } else { 58 return event; 59 } 60 }, 61 isReady: function () { 62 if (typeof $_wp_isActives == 'object' && $_wp_isActives.length > 0) { 63 return true; 64 } else { 65 return false; 66 } 67 }(), 68 isGoogle: function () { 69 return $_wp_isActives.indexOf('ga4') > -1 ? true : false; 70 }(), 71 isFacebookPixel: function () { 72 return $_wp_isActives.indexOf('fbq') > -1 ? true : false; 73 }(), 74 isGoogleTagManager: function () { 75 return $_wp_isActives.indexOf('gtm') > -1 ? true : false; 76 }(), 77 getIp: function () { 78 // disabled here because was used internally 79 // try { 80 // $.getJSON("https://jsonip.com", function (data) { 81 // weasyPixel.ipaddress = data.ip; 82 // }); 83 // } 84 // catch (error) { 85 // weasyPixel.ipaddress = '127.0.0.1'; 86 // } 87 }(), 88 startEvent: function (data) { 89 this.header = {}; 90 this.items = []; 91 this.itemsConv = []; 92 if (typeof data === 'object') this.header = data; 93 }, 94 addEvent: function (data) { 95 if (typeof data === 'object') this.items.push(data); 96 }, 97 sendApiEvent: function (payloadB64, eventName = 'event_PageView') { 98 // purchase can be followed by immediate redirects; try sendBeacon first and fallback to ajax 99 if (eventName === 'event_Purchase' && typeof navigator !== 'undefined' && typeof navigator.sendBeacon === 'function') { 100 try { 101 const formData = new FormData(); 102 formData.append('payload', payloadB64); 103 if (navigator.sendBeacon(weasyPixel.baseUrl, formData)) { 104 return; 105 } 106 } catch (error) { 107 } 108 } 109 110 $.ajax({ 111 type: "POST", 112 url: weasyPixel.baseUrl, 113 data: "payload=" + payloadB64, 114 dataType: "json", 115 success: function (msg) { 116 }, 117 error: function (XMLHttpObj, erroCode) { 118 } 119 }); 120 }, 121 send: function (provider = 'fbq', eventName = 'event_PageView') { 122 123 switch (provider) { 124 case 'fbq': 125 $payload = {}; 126 $payload['action'] = provider;
127 // rfarinelli-460-fbp-unificado - 2025-11-26 128 // create a ident_id for non duplicate 129 weasyPixel.headerConv.event_id = eventName + Date.now() + '-' + Math.floor(Math.random() * 1000); 130 131 weasyPixel.headerConv.event_name = weasyPixel.getEvent(provider, eventName); 132 // Delete invalid properties by events 133 if (weasyPixel.headerConv.event_name != 'CompleteRegistration' && weasyPixel.itemsConv.user_data.hasOwnProperty('status')) delete weasyPixel.itemsConv.user_data.status; 134 135 $payload['header'] = weasyPixel.headerConv; 136 if (weasyPixel.itemsConv.hasOwnProperty('custom_data')) $payload['custom_data'] = weasyPixel.itemsConv.custom_data; 137 if (weasyPixel.itemsConv.hasOwnProperty('user_data')) $payload['user_data'] = weasyPixel.itemsConv.user_data; 138 139 // 1st, send fbq events 140 // 2nd, send api events 141 // 1st: PIXEL BEGIN 142 // se o pixel estiver carregado e o evento for diferente de pageview, faz o envio pelo Pixel. Isso porque se estiver carregado 143 if (fbq && fbq.loaded) { 144 if (eventName !== 'event_PageView') { 145 try { 146 const fbqPayload = {}; 147 // Lista de campos permitidos no Pixel 148 weasyPixel.allowedFields.forEach(field => { 149 if (weasyPixel.itemsConv.custom_data[field] !== undefined) { 150 fbqPayload[field] = weasyPixel.itemsConv.custom_data[field]; 151 } 152 }); 153 fbqPayload.eventID = weasyPixel.headerConv.event_id; 154 if (eventName == 'event_ViewCart' || eventName == 'event_ViewCartBudget' || eventName == 'event_RemoveFromCart' || eventName == 'event_ShippingInfo') { 155 fbq('trackCustom', weasyPixel.headerConv.event_name, fbqPayload); 156 } else { 157 fbq('track', weasyPixel.headerConv.event_name, fbqPayload); 158 } 159 160 } catch (error) { 161 162 } 163 } 164 } 165 // 1st: PIXEL END 166 // 2nd: API BEGIN 167 // by pass because when we have a fbq, this event already sent 168 if ((fbq && fbq.loaded) && eventName == 'event_PageView') { 169 break; 170 } 171 weasyPixel.sendApiEvent(Base64.encode(JSON.stringify($payload)), eventName); 172 // 2nd: API END 173 break; 174 default: 175 break; 176 } 177 }, 178 event_PageView: function (msg) { 179 // alert(msg); 180 181 weasyPixel.isActives.forEach(element => { 182 weasyPixel.convertHeader(element); 183 weasyPixel.convertDetails(element); 184 weasyPixel.send(element, 'event_PageView'); 185 }); 186 }, 187 event_ViewCart: function (msg) { 188 // alert(msg); 189 190 weasyPixel.isActives.forEach(element => { 191 weasyPixel.convertHeader(element); 192 weasyPixel.convertDetails(element); 193 weasyPixel.send(element, 'event_ViewCart'); 194 }); 195 }, 196 event_ViewCartBudget: function (msg) { 197 // alert(msg); 198
199 weasyPixel.isActives.forEach(element => { 200 weasyPixel.convertHeader(element); 201 weasyPixel.convertDetails(element); 202 weasyPixel.send(element, 'event_ViewCartBudget'); 203 }); 204 }, 205 event_Search: function (msg) { 206 // alert(msg); 207 208 weasyPixel.isActives.forEach(element => { 209 weasyPixel.convertHeader(element); 210 weasyPixel.convertDetails(element); 211 weasyPixel.send(element, 'event_Search'); 212 }); 213 }, 214 event_AddToCart: function (msg) { 215 // alert(msg); 216 217 weasyPixel.isActives.forEach(element => { 218 weasyPixel.convertHeader(element); 219 weasyPixel.convertDetails(element); 220 weasyPixel.send(element, 'event_AddToCart'); 221 }); 222 }, 223 event_RemoveFromCart: function (msg) { 224 // alert(msg); 225 226 weasyPixel.isActives.forEach(element => { 227 weasyPixel.convertHeader(element); 228 weasyPixel.convertDetails(element); 229 weasyPixel.send(element, 'event_RemoveFromCart'); 230 }); 231 }, 232 event_AddToWishList: function (msg) { 233 // alert(msg); 234 235 weasyPixel.isActives.forEach(element => { 236 weasyPixel.convertHeader(element); 237 weasyPixel.convertDetails(element); 238 weasyPixel.send(element, 'event_AddToWishList'); 239 }); 240 }, 241 event_ViewProduct: function (msg) { 242 // alert(msg); 243 244 weasyPixel.isActives.forEach(element => { 245 weasyPixel.convertHeader(element); 246 weasyPixel.convertDetails(element); 247 weasyPixel.send(element, 'event_ViewProduct'); 248 }); 249 }, 250 event_StartCheckout: function (msg) { 251 // alert(msg); 252 253 weasyPixel.isActives.forEach(element => { 254 weasyPixel.convertHeader(element); 255 weasyPixel.convertDetails(element); 256 weasyPixel.send(element, 'event_StartCheckout'); 257 }); 258 }, 259 event_ShippingInfo: function (msg) { 260 // alert(msg); 261 262 weasyPixel.isActives.forEach(element => { 263 weasyPixel.convertHeader(element); 264 weasyPixel.convertDetails(element); 265 weasyPixel.send(element, 'event_ShippingInfo'); 266 }); 267 }, 268 event_PaymentInfo: function (msg) { 269 // alert(msg); 270 271 weasyPixel.isActives.forEach(element => { 272 weasyPixel.convertHeader(element); 273 weasyPixel.convertDetails(element); 274 weasyPixel.send(element, 'event_PaymentInfo'); 275 }); 276 }, 277 event_Purchase: function (msg) { 278 // alert(msg); 279 280 weasyPixel.isActives.forEach(element => { 281 weasyPixel.convertHeader(element); 282 weasyPixel.convertDetails(element); 283 // delete elements that can´t be send 284 weasyPixel.send(element, 'event_Purchase'); 285 }); 286 }, 287 event_CustomerRegister: function (msg) { 288 // alert(msg); 289
290 weasyPixel.isActives.forEach(element => { 291 weasyPixel.convertHeader(element); 292 weasyPixel.convertDetails(element); 293 weasyPixel.send(element, 'event_CustomerRegister'); 294 }); 295 }, 296 event_ShippingInfo: function (msg) { 297 // alert(msg); 298 299 weasyPixel.isActives.forEach(element => { 300 weasyPixel.convertHeader(element); 301 weasyPixel.convertDetails(element); 302 weasyPixel.send(element, 'event_ShippingInfo'); 303 }); 304 }, 305 convertHeader: function (provider = 'fbq') { 306 weasyPixel.headerConv = {}; 307 308 switch (provider) { 309 case 'fbq': 310 // BEGIN - Mandatory for all Events 311 weasyPixel.headerConv.event_name = ''; 312 weasyPixel.headerConv.event_time = Date.now(); 313 weasyPixel.headerConv.action_source = 'website'; 314 weasyPixel.headerConv.event_source_url = document.URL; 315 // END - Mandatory for all Events 316 break; 317 318 default: 319 break; 320 } 321 322 }, 323 convertDetails: function (provider = 'fbq') { 324 /* weasyPixel.itemsConv = []; */ 325 326 switch (provider) { 327 case 'fbq': 328 329 for (let index = 0; index < weasyPixel.items.length; index++) { 330 const element = weasyPixel.items[index]; 331 if (index == 0) { 332 // data about items (for the event) (CUSTOM DATA) 333 weasyPixel.itemsConv.custom_data = {}; 334 // data about customer (USER DATA) 335 weasyPixel.itemsConv.user_data = {}; 336 337 // USER DATA 338 // mandatory 339 weasyPixel.itemsConv.user_data.client_ip_address = (weasyPixel.header.hasOwnProperty('ipaddress')) ? weasyPixel.header.ipaddress : weasyPixel.ipaddress; 340 weasyPixel.itemsConv.user_data.client_user_agent = window.navigator.userAgent; 341 // optional 342 weasyPixel.itemsConv.user_data.em = (weasyPixel.header.hasOwnProperty('email')) ? [sha256(weasyPixel.header.email)] : null; 343 weasyPixel.itemsConv.user_data.ph = (weasyPixel.header.hasOwnProperty('phone')) ? [sha256(weasyPixel.header.phone)] : null; 344 weasyPixel.itemsConv.user_data.fn = (weasyPixel.header.hasOwnProperty('fname')) ? sha256(weasyPixel.header.fname) : null; 345 weasyPixel.itemsConv.user_data.ln = (weasyPixel.header.hasOwnProperty('lname')) ? sha256(weasyPixel.header.lname) : null; 346 weasyPixel.itemsConv.user_data.db = (weasyPixel.header.hasOwnProperty('born')) ? sha256(weasyPixel.header.born) : null; 347 weasyPixel.itemsConv.user_data.country = (weasyPixel.header.hasOwnProperty('country')) ? sha256(weasyPixel.header.country) : null; 348 weasyPixel.itemsConv.user_data.ct = (weasyPixel.header.hasOwnProperty('city')) ? sha256(weasyPixel.header.city) : null; 349 weasyPixel.itemsConv.user_data.st = (weasyPixel.header.hasOwnProperty('state')) ? sha256(weasyPixel.header.state) : null; 350 weasyPixel.itemsConv.user_data.zp = (weasyPixel.header.hasOwnProperty('zipcode')) ? sha256(weasyPixel.header.zipcode) : null; 351 weasyPixel.itemsConv.user_data.status = (weasyPixel.header.hasOwnProperty('status')) ? sha256(weasyPixel.header.status) : null; 352 // clean proprierties didn´t sent 353 Object.keys(weasyPixel.itemsConv.user_data).forEac
353h((item) => { 354 if (weasyPixel.itemsConv.user_data[item] === null) delete weasyPixel.itemsConv.user_data[item]; 355 }); 356 // CUSTOM DATA 357 weasyPixel.itemsConv.custom_data.currency = weasyPixel.currencyIso4217; 358 weasyPixel.itemsConv.custom_data.value = (weasyPixel.header.hasOwnProperty('value')) ? (weasyPixel.header.value) : null; 359 weasyPixel.itemsConv.custom_data.content_category = (element.hasOwnProperty('category')) ? (element.category) : null; 360 weasyPixel.itemsConv.custom_data.search_string = (weasyPixel.header.hasOwnProperty('search')) ? (weasyPixel.header.search) : null; 361 weasyPixel.itemsConv.custom_data.delivery_category = (weasyPixel.header.hasOwnProperty('shipping')) ? (weasyPixel.header.shipping) : null; 362 weasyPixel.itemsConv.custom_data.num_items = (weasyPixel.header.hasOwnProperty('totalitems')) ? (weasyPixel.header.totalitems) : null; 363 weasyPixel.itemsConv.custom_data.order_id = (weasyPixel.header.hasOwnProperty('trackingcode')) ? (weasyPixel.header.trackingcode) : null; 364 weasyPixel.itemsConv.custom_data.content_name = (weasyPixel.header.hasOwnProperty('description')) ? (weasyPixel.header.description) : null; 365 weasyPixel.itemsConv.custom_data.content_type = 'product'; 366 weasyPixel.itemsConv.custom_data.content_ids = []; 367 weasyPixel.itemsConv.custom_data.contents = []; 368 // clean proprierties didn´t sent 369 Object.keys(weasyPixel.itemsConv.custom_data).forEach((item) => { 370 if (weasyPixel.itemsConv.custom_data[item] === null) delete weasyPixel.itemsConv.custom_data[item]; 371 }); 372 } 373 if (element.hasOwnProperty('sku')) weasyPixel.itemsConv.custom_data.content_ids.push((element.sku)); 374 if (element.hasOwnProperty('id') && element.hasOwnProperty('quantity') && element.hasOwnProperty('price')) { 375 detail = {}; 376 if (element.hasOwnProperty('id')) detail.id = (element.id); 377 if (element.hasOwnProperty('quantity')) detail.quantity = (element.quantity); 378 if (element.hasOwnProperty('item_price')) detail.item_price = (element.item_price); 379 if (element.hasOwnProperty('brand')) detail.brand = (element.brand); 380 if (element.hasOwnProperty('category')) detail.category = (element.category); 381 if (element.hasOwnProperty('title')) detail.title = (element.title); 382 weasyPixel.itemsConv.custom_data.contents.push(detail); 383 } 384 } 385 // USER_DATA has manatory properties 386 if (!weasyPixel.itemsConv.hasOwnProperty('user_data')) { 387 weasyPixel.itemsConv.user_data = {}; 388 weasyPixel.itemsConv.user_data.client_ip_address = (weasyPixel.header.hasOwnProperty('ipaddress')) ? weasyPixel.header.ipaddress : weasyPixel.ipaddress; 389 weasyPixel.itemsConv.user_data.client_user_agent = window.navigator.userAgent; 390 } 391 392 break; 393 394 default: 395 break; 396 } 397 398 }, 399 } 400 }(); 401 } 402 403 var sha256 = function sha256(ascii) { 404 function rightRotate(value, amount) { 405 return (value >>> amount) | (value << (32 - amount)); 406 }; 407 408 var mathPow = Math.pow; 409 var maxWord = mathPow(2, 32); 410 var lengthProperty = 'length' 411 var i, j; // Used as a counter across the whole file 412 var result = '' 413 414 var words = []; 415 var asciiBitLength = ascii[lengthProperty] * 8; 416
417 //* caching results is optional - remove/add slash from front of this line to toggle 418 // Initial hash value: first 32 bits of the fractional parts of the square roots of the first 8 primes 419 // (we actually calculate the first 64, but extra values are just ignored) 420 var hash = sha256.h = sha256.h || []; 421 // Round constants: first 32 bits of the fractional parts of the cube roots of the first 64 primes 422 var k = sha256.k = sha256.k || []; 423 var primeCounter = k[lengthProperty]; 424 /*/ 425 var hash = [], k = []; 426 var primeCounter = 0; 427 //*/ 428 429 var isComposite = {}; 430 for (var candidate = 2; primeCounter < 64; candidate++) { 431 if (!isComposite[candidate]) { 432 for (i = 0; i < 313; i += candidate) { 433 isComposite[i] = candidate; 434 } 435 hash[primeCounter] = (mathPow(candidate, .5) * maxWord) | 0; 436 k[primeCounter++] = (mathPow(candidate, 1 / 3) * maxWord) | 0; 437 } 438 } 439 440 ascii += '\x80' // Append Æ' bit (plus zero padding) 441 while (ascii[lengthProperty] % 64 - 56) ascii += '\x00' // More zero padding 442 for (i = 0; i < ascii[lengthProperty]; i++) { 443 j = ascii.charCodeAt(i); 444 if (j >> 8) return; // ASCII check: only accept characters in range 0-255 445 words[i >> 2] |= j << ((3 - i) % 4) * 8; 446 } 447 words[words[lengthProperty]] = ((asciiBitLength / maxWord) | 0); 448 words[words[lengthProperty]] = (asciiBitLength) 449 450 // process each chunk 451 for (j = 0; j < words[lengthProperty];) { 452 var w = words.slice(j, j += 16); // The message is expanded into 64 words as part of the iteration 453 var oldHash = hash; 454 // This is now the undefinedworking hash", often labelled as variables a...g 455 // (we have to truncate as well, otherwise extra entries at the end accumulate 456 hash = hash.slice(0, 8); 457 458 for (i = 0; i < 64; i++) { 459 var i2 = i + j; 460 // Expand the message into 64 words 461 // Used below if 462 var w15 = w[i - 15], w2 = w[i - 2]; 463 464 // Iterate 465 var a = hash[0], e = hash[4]; 466 var temp1 = hash[7] 467 + (rightRotate(e, 6) ^ rightRotate(e, 11) ^ rightRotate(e, 25)) // S1 468 + ((e & hash[5]) ^ ((~e) & hash[6])) // ch 469 + k[i] 470 // Expand the message schedule if needed 471 + (w[i] = (i < 16) ? w[i] : ( 472 w[i - 16] 473 + (rightRotate(w15, 7) ^ rightRotate(w15, 18) ^ (w15 >>> 3)) // s0 474 + w[i - 7] 475 + (rightRotate(w2, 17) ^ rightRotate(w2, 19) ^ (w2 >>> 10)) // s1 476 ) | 0 477 ); 478 // This is only used once, so *could* be moved below, but it only saves 4 bytes and makes things unreadble 479 var temp2 = (rightRotate(a, 2) ^ rightRotate(a, 13) ^ rightRotate(a, 22)) // S0 480 + ((a & hash[1]) ^ (a & hash[2]) ^ (hash[1] & hash[2])); // maj 481 482 hash = [(temp1 + temp2) | 0].concat(hash); // We don't bother trimming off the extra ones, they're harmless as long as we're truncating when we do the slice() 483 hash[4] = (hash[4] + temp1) | 0; 484 } 485 486 for (i = 0; i < 8; i++) { 487 hash[i] = (hash[i] + oldHash[i]) | 0; 488 } 489 } 490 491 for (i = 0; i < 8; i++) { 492 for (j = 3; j + 1; j--) { 493 var b = (hash[i] >> (j * 8)) & 255; 494 result += ((b < 16) ? 0 : '') + b.toString(16); 495 } 496 } 497 return result; 498 }; 499 // weasyPixel.startEvent(); 500 // weasyPixel.event_PageView('event_pageviewInicial'); 501 502});
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.