1var gtm4wp_last_selected_product_variation; 2var gtm4wp_changedetail_fired_during_pageload=false; 3 4function gtm4wp_handle_cart_qty_change() { 5 jQuery( '.product-quantity input.qty' ).each(function() { 6 var _original_value = jQuery( this ).prop( 'defaultValue' ); 7 8 var _current_value = parseInt( jQuery( this ).val() ); 9 if ( Number.isNaN( _current_value ) ) { 10 _current_value = _original_value; 11 } 12 13 if ( _original_value != _current_value ) { 14 var productdata = jQuery( this ).closest( '.cart_item' ).find( '.remove' ); 15 var productprice = productdata.data( 'gtm4wp_product_price' ); 16 17 if ( typeof productprice == "string" ) { 18 productprice = parseFloat( productprice ); 19 if ( isNaN( productprice ) ) { 20 productprice = 0; 21 } 22 } else if ( typeof productprice != "number" ) { 23 productprice = 0; 24 } 25 26 if ( _original_value < _current_value ) { 27 window[ gtm4wp_datalayer_name ].push({ 28 'event': 'gtm4wp.addProductToCartEEC', 29 'ecommerce': { 30 'currencyCode': gtm4wp_currency, 31 'add': { 32 'products': [{ 33 'name': productdata.data( 'gtm4wp_product_name' ), 34 'id': productdata.data( 'gtm4wp_product_id' ), 35 'price': productprice.toFixed(2), 36 'category': productdata.data( 'gtm4wp_product_cat' ), 37 'variant': productdata.data( 'gtm4wp_product_variant' ), 38 'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ), 39 'brand': productdata.data( 'gtm4wp_product_brand' ), 40 'quantity': _current_value - _original_value 41 }] 42 } 43 } 44 }); 45 } else { 46 window[ gtm4wp_datalayer_name ].push({ 47 'event': 'gtm4wp.removeFromCartEEC', 48 'ecommerce': { 49 'currencyCode': gtm4wp_currency, 50 'remove': { 51 'products': [{ 52 'name': productdata.data( 'gtm4wp_product_name' ), 53 'id': productdata.data( 'gtm4wp_product_id' ), 54 'price': productprice.toFixed(2), 55 'category': productdata.data( 'gtm4wp_product_cat' ), 56 'variant': productdata.data( 'gtm4wp_product_variant' ), 57 'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ), 58 'brand': productdata.data( 'gtm4wp_product_brand' ), 59 'quantity': _original_value - _current_value 60 }] 61 } 62 } 63 }); 64 } 65 } // end if qty changed 66 }); // end each qty field 67} // end gtm4wp_handle_cart_qty_change() 68 69jQuery(function() { 70 var is_cart = jQuery( 'body' ).hasClass( 'woocommerce-cart' ); 71 var is_checkout = jQuery( 'body' ).hasClass( 'woocommerce-checkout' ); 72 73 // track impressions of products in product lists 74 if ( jQuery( '.gtm4wp_productdata,.widget-product-item' ).length > 0 ) { 75 var products = []; 76 var productdata, productprice=0; 77 jQuery( '.gtm4wp_productdata,.widget-product-item' ).each( function() { 78 productdata = jQuery( this ); 79 productprice = productdata.data( 'gtm4wp_product_price' ); 80 81 if ( typeof productprice == "string" ) { 82 productprice = parseFloat( productprice ); 83 if ( isNaN( productprice ) ) { 84 productprice = 0; 85 } 86 } else if ( typeof productprice != "number" ) { 87 productprice = 0; 88 } 89 90 products.push({ 91 'name': productdata.data( 'gtm4wp_product_name' ), 92 'id': productdata.data( 'gtm4wp_product_id' ), 93 'price': productprice.toFixed(2), 94 'category': productdata.data( 'gtm4wp_product_cat' ), 95 'position': productdata.data( 'gtm4wp_product_listposition' ), 96 'list': productdata.data( 'gtm4wp_productlist_name' ), 97 'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ), 98 'brand': productdata.data( 'gtm4wp_product_brand' ) 99 }); 100 101 }); 102 103 if ( gtm4wp_product_per_impression > 0 ) { 104 // Need to split the product submissions up into chunks in order to avoid the GA 8kb submission limit 105 var chunk; 106 while ( products.length ) { 107 chunk = products.splice( 0, gtm4wp_product_per_impression ); 108 109 window[ gtm4wp_datalayer_name ].push({ 110 'event': 'gtm4wp.productImpressionEEC', 111 'ecommerce': { 112 'currencyCode': gtm4wp_currency, 113 'impressions': chunk 114 } 115 }); 116 } 117 } else { 118 for( var i=0; i<window[ gtm4wp_datalayer_name ].length; i++ ) { 119 if ( window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ] ) { 120 121 if ( ! window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ][ 'impressions' ] ) { 122 window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ][ 'impressions' ] = products; 123 } else { 124 window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ][ 'impressions' ] = window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ][ 'impressions' ].concat( products ); 125 } 126 127 break; 128 } 129 } 130 131 if ( i == window[ gtm4wp_datalayer_name ].length ) { 132 // no existing ecommerce data found in the datalayer 133 i = 0; 134 window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ] = {}; 135 window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ][ 'impressions' ] = products; 136 } 137 138 window[ gtm4wp_datalayer_name ][ i ][ 'ecommerce' ][ 'currencyCode' ] = gtm4wp_currency; 139 140 } 141 } 142 143 // track add to cart events for simple products in product lists 144 jQuery( document ).on( 'click', '.add_to_cart_button:not(.product_type_variable, .product_type_grouped, .single_add_to_cart_button)', function() { 145 var productdata = jQuery( this ).closest( '.product' ).find( '.gtm4wp_productdata' ); 146 var productprice = productdata.data( 'gtm4wp_product_price' ); 147 148 if ( typeof productprice == "string" ) { 149 productprice = parseFloat( productprice ); 150 if ( isNaN( productprice ) ) { 151 productprice = 0; 152 } 153 } else if ( typeof productprice != "number" ) { 154 productprice = 0; 155 } 156 157 window[ gtm4wp_datalayer_name ].push({ 158 'event': 'gtm4wp.addProductToCartEEC', 159 'ecommerce': { 160 'currencyCode': gtm4wp_currency, 161 'add': { 162 'products': [{ 163 'name': productdata.data( 'gtm4wp_product_name' ), 164 'id': productdata.data( 'gtm4wp_product_id' ), 165 'price': productprice.toFixed(2), 166 'category': productdata.data( 'gtm4wp_product_cat' ), 167 'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ), 168 'brand': productdata.data( 'gtm4wp_product_brand' ), 169 'quantity': 1 170 }] 171 } 172 } 173 }); 174 }); 175 176 // track add to cart events for products on product detail pages 177 jQuery( document ).on( 'click', '.single_add_to_cart_button', function() { 178 var _product_form = jQuery( this ).closest( 'form.cart' ); 179 var _product_var_id = jQuery( '[name=variation_id]', _product_form );
180 var _product_is_grouped = jQuery( _product_form ).hasClass( 'grouped_form' ); 181 182 if ( _product_var_id.length > 0 ) { 183 if ( gtm4wp_last_selected_product_variation ) { 184 gtm4wp_last_selected_product_variation.quantity = jQuery( 'form.cart:first input[name=quantity]' ).val(); 185 186 window[ gtm4wp_datalayer_name ].push({ 187 'event': 'gtm4wp.addProductToCartEEC', 188 'ecommerce': { 189 'currencyCode': gtm4wp_currency, 190 'add': { 191 'products': [gtm4wp_last_selected_product_variation] 192 } 193 } 194 }); 195 } 196 } else if ( _product_is_grouped ) { 197 var _products_in_group = jQuery( '.grouped_form .gtm4wp_productdata' ); 198 var _products_eec = []; 199 200 _products_in_group.each( function() { 201 var productdata = jQuery( this ); 202 203 var product_qty_input = jQuery( 'input[name=quantity\\[' + productdata.data( 'gtm4wp_product_id' ) + '\\]]' ); 204 if ( product_qty_input.length > 0 ) { 205 product_qty = product_qty_input.val(); 206 } else { 207 return; 208 } 209 210 if ( 0 == product_qty ) { 211 return; 212 } 213 214 _products_eec.push({ 215 'id': gtm4wp_use_sku_instead ? productdata.data( 'gtm4wp_product_sku' ) : productdata.data( 'gtm4wp_product_id' ), 216 'name': productdata.data( 'gtm4wp_product_name' ), 217 'price': productdata.data( 'gtm4wp_product_price' ), 218 'category': productdata.data( 'gtm4wp_product_cat' ), 219 'quantity': product_qty, 220 'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ), 221 'brand': productdata.data( 'gtm4wp_product_brand' ) 222 }); 223 }); 224 225 if ( 0 == _products_eec.length ) { 226 return; 227 } 228 229 window[ gtm4wp_datalayer_name ].push({ 230 'event': 'gtm4wp.addProductToCartEEC', 231 'ecommerce': { 232 'currencyCode': gtm4wp_currency, 233 'add': { 234 'products': _products_eec 235 } 236 } 237 }); 238 } else { 239 window[ gtm4wp_datalayer_name ].push({ 240 'event': 'gtm4wp.addProductToCartEEC', 241 'ecommerce': { 242 'currencyCode': gtm4wp_currency, 243 'add': { 244 'products': [{ 245 'id': gtm4wp_use_sku_instead ? jQuery( '[name=gtm4wp_sku]', _product_form ).val() : jQuery( '[name=gtm4wp_id]', _product_form ).val(), 246 'name': jQuery( '[name=gtm4wp_name]', _product_form ).val(), 247 'price': jQuery( '[name=gtm4wp_price]', _product_form ).val(), 248 'category': jQuery( '[name=gtm4wp_category]', _product_form ).val(), 249 'quantity': jQuery( 'form.cart:first input[name=quantity]' ).val(), 250 'stocklevel': jQuery( '[name=gtm4wp_stocklevel]', _product_form ).val(), 251 'brand': jQuery( '[name=gtm4wp_brand]', _product_form ).val() 252 }] 253 } 254 } 255 }); 256 } 257 }); 258 259 // track remove links in mini cart widget and on cart page 260 jQuery( document ).on( 'click', '.mini_cart_item a.remove,.product-remove a.remove', function() { 261 var productdata = jQuery( this ); 262 263 var qty = 0; 264 var qty_element = jQuery( this ).closest( '.cart_item' ).find( '.product-quantity input.qty' ); 265 if ( qty_element.length === 0 ) { 266 qty_element = jQuery( this ).closest( '.mini_cart_item' ).find( '.quantity' ); 267 if ( qty_element.length > 0 ) { 268 qty = parseInt( qty_element.text() ); 269 270 if ( Number.isNaN( qty ) ) { 271 qty = 0; 272 } 273 } 274 } else { 275 qty = qty_element.val(); 276 } 277 278 if ( qty === 0 ) { 279 return true; 280 } 281 282 window[ gtm4wp_datalayer_name ].push({ 283 'event': 'gtm4wp.removeFromCartEEC', 284 'ecommerce': { 285 'remove': { 286 'products': [{ 287 'name': productdata.data( 'gtm4wp_product_name' ), 288 'id': productdata.data( 'gtm4wp_product_id' ), 289 'price': productdata.data( 'gtm4wp_product_price' ), 290 'category': productdata.data( 'gtm4wp_product_cat' ), 291 'variant': productdata.data( 'gtm4wp_product_variant' ), 292 'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ), 293 'brand': productdata.data( 'gtm4wp_product_brand' ), 294 'quantity': qty 295 }] 296 } 297 } 298 }); 299 }); 300 301 // track clicks in product lists 302 jQuery( document ).on( 'click', '.products li:not(.product-category) a:not(.add_to_cart_button):not(.quick-view-button),.products>div:not(.product-category) a:not(.add_to_cart_button):not(.quick-view-button),.widget-product-item,.woocommerce-grouped-product-list-item__label a', function( event ) {
303 // do nothing if GTM is blocked for some reason 304 if ( 'undefined' == typeof google_tag_manager ) { 305 return true; 306 } 307 308 var _productdata = jQuery( this ).closest( '.product' ); 309 var productdata = ''; 310 311 if ( _productdata.length > 0 ) { 312 productdata = _productdata.find( '.gtm4wp_productdata' ); 313 314 } else { 315 _productdata = jQuery( this ).closest( '.products li' ); 316 317 if ( _productdata.length > 0 ) { 318 productdata = _productdata.find( '.gtm4wp_productdata' ); 319 320 } else { 321 _productdata = jQuery( this ).closest( '.products>div' ); 322 323 if ( _productdata.length > 0 ) { 324 productdata = _productdata.find( '.gtm4wp_productdata' ); 325 326 } else { 327 _productdata = jQuery( this ).closest( '.woocommerce-grouped-product-list-item__label' ); 328 329 if ( _productdata.length > 0 ) { 330 productdata = _productdata.find( '.gtm4wp_productdata' ); 331 } else { 332 productdata = jQuery( this ); 333 } 334 } 335 } 336 } 337 338 if ( ( 'undefined' == typeof productdata.data( 'gtm4wp_product_id' ) ) || ( '' == productdata.data( 'gtm4wp_product_id' ) ) ) { 339 return true; 340 } 341 342 // only act on links pointing to the product detail page 343 if ( productdata.data( 'gtm4wp_product_url' ) != jQuery( this ).attr( 'href' ) ) { 344 return true; 345 } 346 347 var ctrl_key_pressed = event.ctrlKey || event.metaKey; 348 349 event.preventDefault(); 350 if ( ctrl_key_pressed ) { 351 // we need to open the new tab/page here so that popup blocker of the browser doesn't block our code 352 var _productpage = window.open( 'about:blank', '_blank' ); 353 } 354 355 window[ gtm4wp_datalayer_name ].push({ 356 'event': 'gtm4wp.productClickEEC', 357 'ecommerce': { 358 'currencyCode': gtm4wp_currency, 359 'click': { 360 'actionField': {'list': productdata.data( 'gtm4wp_productlist_name' )}, 361 'products': [{ 362 'id': productdata.data( 'gtm4wp_product_id' ), 363 'name': productdata.data( 'gtm4wp_product_name' ), 364 'price': productdata.data( 'gtm4wp_product_price' ), 365 'category': productdata.data( 'gtm4wp_product_cat' ), 366 'stocklevel': productdata.data( 'gtm4wp_product_stocklevel' ), 367 'brand': productdata.data( 'gtm4wp_product_brand' ), 368 'position': productdata.data( 'gtm4wp_product_listposition' ) 369 }] 370 } 371 }, 372 'eventCallback': function() { 373 if ( ctrl_key_pressed && _productpage ) { 374 _productpage.location.href= productdata.data( 'gtm4wp_product_url' ); 375 } else { 376 document.location.href = productdata.data( 'gtm4wp_product_url' ); 377 } 378 }, 379 'eventTimeout': 2000 380 }); 381 }); 382 383 // track variable products on their detail pages 384 jQuery( document ).on( 'found_variation', function( event, product_variation ) { 385 if ( "undefined" == typeof product_variation ) { 386 // some ither plugins trigger this event without variation data 387 return; 388 } 389 390 if ( (document.readyState === "interactive") && gtm4wp_changedetail_fired_during_pageload ) { 391 // some custom attribute rendering plugins fire this event multiple times during page load 392 return; 393 } 394 395 var _product_form = event.target; 396 var _product_var_id = jQuery( '[name=variation_id]', _product_form ); 397 var _product_id = jQuery( '[name=gtm4wp_id]', _product_form ).val(); 398 var _product_name = jQuery( '[name=gtm4wp_name]', _product_form ).val(); 399 var _product_sku = jQuery( '[name=gtm4wp_sku]', _product_form ).val(); 400 var _product_category = jQuery( '[name=gtm4wp_category]', _product_form ).val(); 401 var _product_price = jQuery( '[name=gtm4wp_price]', _product_form ).val(); 402 var _product_stocklevel = jQuery( '[name=gtm4wp_stocklevel]', _product_form ).val(); 403 var _product_brand = jQuery( '[name=gtm4wp_brand]', _product_form ).val(); 404 405 var current_product_detail_data = { 406 name: _product_name, 407 id: 0, 408 price: 0, 409 category: _product_category, 410 stocklevel: _product_stocklevel, 411 brand: _product_brand, 412 variant: '' 413 }; 414 415 current_product_detail_data.id = product_variation.variation_id; 416 if ( gtm4wp_use_sku_instead && product_variation.sku && ('' !== product_variation.sku) ) { 417 current_product_detail_data.id = product_variation.sku; 418 } 419 current_product_detail_data.price = product_variation.display_price; 420 421 var _tmp = []; 422 for( var attrib_key in product_variation.attributes ) { 423 _tmp.push( product_variation.attributes[ attrib_key ] ); 424 } 425 current_product_detail_data.variant = _tmp.join(','); 426 gtm4wp_last_selected_product_variation = current_product_detail_data; 427 428 window[ gtm4wp_datalayer_name ].push({
429 'event': 'gtm4wp.changeDetailViewEEC', 430 'ecommerce': { 431 'currencyCode': gtm4wp_currency, 432 'detail': { 433 'products': [current_product_detail_data] 434 }, 435 }, 436 'ecomm_prodid': gtm4wp_id_prefix + current_product_detail_data.id, 437 'ecomm_pagetype': 'product', 438 'ecomm_totalvalue': current_product_detail_data.price, 439 }); 440 441 if ( document.readyState === "interactive" ) { 442 gtm4wp_changedetail_fired_during_pageload = true; 443 } 444 }); 445 jQuery( '.variations select' ).trigger( 'change' ); 446 447 // initiate codes in WooCommere Quick View 448 jQuery( document ).ajaxSuccess( function( event, xhr, settings ) { 449 if(typeof settings !== 'undefined') { 450 if (settings.url.indexOf( 'wc-api=WC_Quick_View' ) > -1 ) { 451 setTimeout( function() { 452 jQuery( ".woocommerce.quick-view" ).parent().find( "script" ).each( function(i) { 453 eval( jQuery( this ).text() ); 454 }); 455 }, 500); 456 } 457 } 458 }); 459 460 // codes for enhanced ecommerce events on cart page 461 if ( is_cart ) { 462 jQuery( document ).on( 'click', '[name=update_cart]', function() { 463 gtm4wp_handle_cart_qty_change(); 464 }); 465 466 jQuery( document ).on( 'keypress', '.woocommerce-cart-form input[type=number]', function() { 467 gtm4wp_handle_cart_qty_change(); 468 }); 469 } 470 471 // codes for enhanced ecommerce events on checkout page 472 if ( is_checkout ) { 473 window.gtm4wp_checkout_step_offset = window.gtm4wp_checkout_step_offset || 0; 474 window.gtm4wp_checkout_products = window.gtm4wp_checkout_products || []; 475 var gtm4wp_shipping_payment_method_step_offset = window.gtm4wp_needs_shipping_address ? 0 : -1; 476 var gtm4wp_checkout_step_fired = []; // step 1 will be the billing section which is reported during pageload, no need to handle here 477 478 jQuery( document ).on( 'blur', 'input[name^=shipping_]:not(input[name^=shipping_method])', function() { 479 // do not report checkout step if already reported 480 if ( gtm4wp_checkout_step_fired.indexOf( 'shipping' ) > -1 ) { 481 return; 482 } 483 484 // do not report checkout step if user is traversing through the section without filling in any data 485 if ( jQuery( this ).val().trim() == '' ) { 486 return; 487 } 488 489 window[ gtm4wp_datalayer_name ].push({ 490 'event': 'gtm4wp.checkoutStepEEC', 491 'ecommerce': { 492 'checkout': { 493 'actionField': { 494 'step': 2 + window.gtm4wp_checkout_step_offset 495 }, 496 'products': window.gtm4wp_checkout_products 497 } 498 } 499 }); 500 501 gtm4wp_checkout_step_fired.push( 'shipping' ); 502 }); 503 504 jQuery( document ).on( 'change', 'input[name^=shipping_method]', function() { 505 // do not report checkout step if already reported 506 if ( gtm4wp_checkout_step_fired.indexOf( 'shipping_method' ) > -1 ) { 507 return; 508 } 509 510 // do not fire event during page load 511 if ( 'complete' != document.readyState ) { 512 return; 513 } 514 515 window[ gtm4wp_datalayer_name ].push({ 516 'event': 'gtm4wp.checkoutStepEEC', 517 'ecommerce': { 518 'checkout': { 519 'actionField': { 520 'step': 3 + window.gtm4wp_checkout_step_offset + gtm4wp_shipping_payment_method_step_offset 521 }, 522 'products': window.gtm4wp_checkout_products 523 } 524 } 525 }); 526 527 gtm4wp_checkout_step_fired.push( 'shipping_method' ); 528 }); 529 530 jQuery( document ).on( 'change', 'input[name=payment_method]', function() { 531 // do not report checkout step if already reported 532 if ( gtm4wp_checkout_step_fired.indexOf( 'payment_method' ) > -1 ) { 533 return; 534 } 535 536 // do not fire event during page load 537 if ( 'complete' != document.readyState ) { 538 return; 539 } 540 541 window[ gtm4wp_datalayer_name ].push({ 542 'event': 'gtm4wp.checkoutStepEEC', 543 'ecommerce': { 544 'checkout': { 545 'actionField': { 546 'step': 4 + window.gtm4wp_checkout_step_offset + gtm4wp_shipping_payment_method_step_offset 547 }, 548 'products': window.gtm4wp_checkout_products 549 } 550 } 551 }); 552 553 gtm4wp_checkout_step_fired.push( 'payment_method' ); 554 }); 555 556 jQuery( 'form[name=checkout]' ).on( 'submit', function() { 557 if ( gtm4wp_checkout_step_fired.indexOf( 'shipping_method' ) == -1 ) { 558 // shipping methods are not visible if only one is available 559 // and if the user has already a pre-selected method, no click event will fire to report the checkout step 560 var selected_shipping_method = jQuery( 'input[name^=shipping_method]:checked' ); 561 if ( selected_shipping_method.length == 0 ) { 562 selected_shipping_method = jQuery( 'input[name^=shipping_method]:first' ); 563 } 564 if ( selected_shipping_method.length > 0 ) { 565 selected_shipping_method.trigger( 'change' ); 566 } 567 } 568 569 if ( gtm4wp_checkout_step_fired.indexOf( 'payment_method' ) == -1 ) { 570 // if the user has already a pre-selected method, no click event will fire to report the checkout step 571 jQuery( 'input[name=payment_method]:checked' ).trigger( 'change' ); 572 } 573 574 var _shipping_el = jQuery( 'input[name^=shipping_method]:checked' ); 575 if ( _shipping_el.length == 0 ) { 576 _shipping_el = jQuery( 'input[name^=shipping_method]:first' ); 577 } 578 if ( _shipping_el.length > 0 ) { 579 window[ gtm4wp_datalayer_name ].push({ 580 'event': 'gtm4wp.checkoutOptionEEC', 581 'ecommerce': { 582 'checkout_option': { 583 'actionField': { 584 'step': 3 + window.gtm4wp_checkout_step_offset + gtm4wp_shipping_payment_method_step_offset, 585 'option': 'Shipping: ' + _shipping_el.val() 586 } 587 } 588 } 589 }); 590 } 591 592 var _payment_el = jQuery( '.payment_methods input:checked' ); 593 if ( _payment_el.length > 0 ) { 594 window[ gtm4wp_datalayer_name ].push({ 595 'event': 'gtm4wp.checkoutOptionEEC', 596 'ecommerce': { 597 'checkout_option': { 598 'actionField': { 599 'step': 4 + window.gtm4wp_checkout_step_offset + gtm4wp_shipping_payment_method_step_offset, 600 'option': 'Payment: ' + _payment_el.val() 601 } 602 } 603 } 604 }); 605 } 606 }); 607 } 608 609 // codes for Google Ads dynamic remarketing 610 if ( window.gtm4wp_remarketing&& !is_cart && !is_checkout ) { 611 if ( jQuery( '.gtm4wp_productdata' ).length > 0 ) { 612 for( var i=0; i<window[ gtm4wp_datalayer_name ].length; i++ ) { 613 if ( window[ gtm4wp_datalayer_name ][ i ][ 'ecomm_prodid' ] ) { 614 break; 615 } 616 } 617 618 if ( i == window[ gtm4wp_datalayer_name ].length ) { 619 // no existing dyn remarketing data found in the datalayer 620 i = 0; 621 window[ gtm4wp_datalayer_name ][ i ][ 'ecomm_prodid' ] = []; 622 } 623 624 if ( 'undefined' == typeof window[ gtm4wp_datalayer_name ][ i ][ 'ecomm_prodid' ].push ) { 625 return false;
626 } 627 628 var productdata; 629 jQuery( '.gtm4wp_productdata' ).each( function() { 630 productdata = jQuery( this ); 631 632 window[ gtm4wp_datalayer_name ][ i ][ 'ecomm_prodid' ].push( gtm4wp_id_prefix + productdata.data( 'gtm4wp_product_id' ) ); 633 }); 634 } 635 } 636});
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.