1var _learnq = _learnq || []; 2var klaviyoTrack = function() { 3 if($('.webshop-productinfo').html()) { 4 var arrCategories = []; 5 $('span[itemprop="itemListElement"]').each(function() { 6 arrCategories.push($(this).find('span[itemprop="name"]').text()); 7 }); 8 9 var name = $('h1 span[itemprop="name"]').text(); 10 var image = $('meta[property="og:image"]').attr('content'); 11 var url = $('meta[property="og:url"]').attr('content'); 12 var brand = $('span[itemprop="brand"] a').first().text(); 13 var price = $('span[itemprop="price"]').attr('content'); 14 15 if (AddedToBasketMessageTriggered) { 16 17 var products = []; 18 19 $.getJSON("/shop/ajaxwrapper.asp?fc=getsessionvaluesJSON").done(function(json) { 20 21 var domain = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : ''); 22 var total = json.basketTotalProductPriceWithoutVat + json.basketTotalVat; 23 24 $(json.basket).each(function(key,basket) { 25 products.push({ 26 "ProductID": basket.productNumber, 27 "ProductName": basket.productName, 28 "Quantity": basket.quantity, 29 "ItemPrice": basket.unitPrice, 30 "RowTotal": basket.totalPrice, 31 "ProductURL": domain + '/shop/default.asp?productid=' + basket.productNumber, 32 "ImageURL": domain + basket.productImageUrl, 33 }); 34 }); 35 36 _learnq.push(["track", "Added to Cart", { 37 "$value": total, 38 "AddedItemProductName": name, 39 "AddedItemProductID": ProductNumber, 40 "AddedItemCategories": arrCategories, 41 "AddedItemImageURL": image, 42 "AddedItemURL": url, 43 "AddedItemPrice": price, 44 "AddedItemQuantity": 1, 45 "CheckoutURL": domain + '/shop/checkout.html', 46 "Items": products 47 }]); 48 49 }); 50 } 51 else { 52 var item = { 53 "ProductName": name, 54 "ProductID": ProductNumber, 55 "Categories": arrCategories, 56 "ImageURL": image, 57 "URL":url , 58 "Brand": brand, 59 "Price": price 60 }; 61 _learnq.push(["track", "Viewed Product", item]); 62 63 _learnq.push(["trackViewedItem", { 64 "Title": item.ProductName, 65 "ItemId": item.ProductID, 66 "Categories": item.Categories, 67 "ImageUrl": item.ImageURL, 68 "Url": item.URL, 69 "Metadata": { 70 "Brand": item.Brand, 71 "Price": item.Price 72 } 73 }]); 74 } 75 } 76 77 if($('.webshop-checkout').html()) { 78 $.getJSON("/shop/ajaxwrapper.asp?fc=getsessionvaluesJSON").done(function(json) { 79 var items = []; 80 var item; 81 var names = []; 82 var strAmount = '';var strProductID = ''; var strVariantGroups = ''; var strVariants = ''; 83 $(json.basket).each(function(key,value) { 84 if (value.unitPrice > 0) { 85 names.push(value.productName); 86 item = { 87 "ProductID": value.productNumber, 88 "SKU": value.productNumber, 89 "ProductName": value.productName, 90 "variantGroupText": value.variantGroupText, 91 "variantText": value.variantText, 92 "ProductURL": location.href.replace('/shop/checkout.html','')+$('#order-summary a').filter(function(index) { return $(this).text() === value.productName; }).attr('href'), 93 "ImageURL": location.href.replace('/shop/checkout.html','')+value.productImageUrl, 94 "Quantity": value.quantity, 95 "ItemPrice": value.unitPrice*((json.vatPercentage/100)+1), 96 "RowTotal": value.totalPrice*((json.vatPercentage/100)+1) 97 } 98 99 items.push(item); 100 101 //basket link 102 strAmount += '|' + value.quantity; 103 strProductID += '|' + value.productNumber; 104 strVariantGroups += '|'; 105 strVariants += '|'; 106 } 107 }); 108 109 //send to Klayiyo 110 var date = new Date; 111 var timeStamp = date.getTime(); 112 113 _learnq.push(["track", "Started Checkout", { 114 "$event_id": json.uniqueSessionIdentifier+ '_' + timeStamp, 115 "$value": json.basketTotalProductPriceWithoutVat*((json.vatPercentage/100)+1), 116 "ItemNames": names, 117 "CheckoutURL": location.href.replace('/shop/checkout.html','')+'/shop/showbasket.html?BasketLink=1&AddMultiple=1&ProductID='+strProductID+'&Amount='+strAmount+'&VariantGroups='+strVariantGroups+'&Variants='+strVariants, 118 "Items": items 119 }]); 120 }); 121 } 122} 123 124$(function() { 125 if (CookiePolicy.allowTrackingCookies) { 126 klaviyoTrack(); 127 } 128 129 if ($('.webshop-customercenter').html() && CookiePolicy.allowTrackingCookies) { 130 $.get('/shop/checkout.html?rawxml=1', function (data) { 131 cusMail = $(data).find('InvoiceField#email').find('Value').text(); 132 _learnq.push(['identify', { 133 '$email' : encodeURI(cusMail), 134 '$consent' : 'email', 135 '$consent_method' : 'login', 136 }]); 137 }); 138 } 139 if($('.webshop-checkout').html()) { 140 $(document).on('change','#newslettersignup', function(){ 141 if($(this).is(':checked')) { 142 $('#res5').val('true'); 143 } 144 else { 145 $('#res5').val(''); 146 } 147 }); 148 if (CookiePolicy.allowTrackingCookies) { 149 $(document).on('blur','#checkout_customer_email', function(){ 150 _learnq.push(['identify', { 151 '$email' : encodeURI($("#checkout_customer_email").val()), 152 '$consent' : 'email', 153 '$consent_method' : 'checkout', 154 }]); 155 }); 156 $(document).on('click','#acceptTermsBit', function(){ 157 _learnq.push(['identify', { 158 '$email' : encodeURI($("#checkout_customer_email").val()), 159 '$consent' : 'email', 160 '$consent_method' : 'checkout', 161 }]); 162 }); 163 } 164 } 165 });
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.