1let GA = { 2 virtualPageview: function(url, page_title){ 3 window.dataLayer.push({ 4 event : "VirtualPageview", 5 virtualPageURL : url, 6 virtualPageTitle : page_title 7 }); 8 }, 9 10 Ecomm: { 11 12 viewPromotion: function(promotion){ 13 window.dataLayer.push({ 14 event: "viewPromotion", 15 ecommerce: { 16 promotion: promotion 17 } 18 }); 19 }, 20 21 selectPromotion: function(promotion){ 22 window.dataLayer.push({ 23 event: "selectPromotion", 24 ecommerce: { 25 promotion: promotion 26 } 27 }); 28 }, 29 30 viewProductList: function(){ 31 let items = []; 32 document.querySelectorAll('.browse-product-container').forEach(function(product, i){ 33 if(product.closest(".products-container")){ 34 items.push({ 35 item_name: product.querySelector(".product-title-cell a").textContent, 36 item_id: product.dataset.sku, 37 price: product.dataset.price, 38 item_brand: product.dataset.brand, 39 item_category: product.dataset.category, 40 item_list_name: product.closest(".products-container").dataset.list_mode, 41 currency: "GBP", 42 index: (i + 1), 43 quantity: 1 44 }); 45 } 46 }); 47 48 if(items.length > 0){ 49 window.dataLayer.push({ 50 event: "viewProductList", 51 ecommerce: { 52 items: items 53 } 54 }); 55 } 56 }, 57 58 productClick: function(product){ 59 window.dataLayer.push({ 60 event: "productClick", 61 ecommerce: { 62 items: [{ 63 item_name: product.name, 64 item_id: product.id, 65 price: product.price, 66 item_brand: product.brand, 67 item_category: product.category, 68 item_list_name: product.list_type, 69 currency: 'GBP', 70 index: product.position, 71 quantity: 1 72 }] 73 } 74 }); 75 }, 76 77 viewProductDetail: function(){ 78 const item = window.Product.item; 79 window.dataLayer.push({ 80 event: "viewItem", 81 ecommerce: { 82 items: [{ 83 item_name: item.title, 84 item_id: item.sku, 85 price: item.price, 86 item_brand: item.brand, 87 item_category: item.category, 88 currency: 'GBP', 89 quantity: 1 90 }] 91 } 92 }); 93 }, 94 95 addToCart: function(product) { 96 window.dataLayer.push({ 97 event: "addToCart", 98 ecommerce: { 99 currency: 'GBP', 100 value: Number(product.price) * Number(product.quantity), 101 items: [{ 102 item_name: product.title, 103 item_id: product.sku, 104 price: Number(product.price), 105 item_brand: product.brand, 106 item_category: product.category, 107 currency: 'GBP', 108 quantity: Number(product.quantity) 109 }] 110 } 111 }); 112 }, 113 114 addToWishlist: function() { 115 window.dataLayer.push({ 116 event: "addToWishlist", 117 ecommerce: { 118 items: [{ 119 item_name: window.Product.title, 120 item_id: window.Product.sku, 121 price: window.Product.price, 122 item_brand: window.Product.brand, 123 item_category: window.Product.category, 124 currency: 'GBP', 125 quantity: 1 126 }] 127 } 128 }); 129 }, 130 131 removeFromCart: function(product) { 132 window.dataLayer.push({ 133 event: "removeFromCart", 134 ecommerce: { 135 items: [{ 136 item_name: product.title, 137 item_id: product.sku, 138 price: product.price, 139 item_brand: product.brand, 140 item_category: product.category, 141 currency: "GBP", 142 quantity: parseInt(product.quantity) 143 }] 144 } 145 }); 146 }, 147 148 viewCart: function(){ 149 let items = []; 150 document.querySelectorAll(".basket.row.item").forEach(function(item){ 151 items.push({ 152 item_name: item.querySelector("a.basket-product-link").textContent, 153 item_id: item.dataset.sku, 154 price: item.dataset.price, 155 item_brand: item.dataset.brand, 156 item_category: item.dataset.category, 157 currency: "GBP", 158 quantity: (item.querySelector('.quantity') ? parseInt(item.querySelector('.quantity').value) : 1) 159 }); 160 }); 161 162 window.dataLayer.push({ 163 event: "viewCart", 164 ecommerce: { 165 items: items 166 } 167 }); 168 }, 169 170 beginCheckout: function() { 171 let items = []; 172 document.querySelectorAll('.basket-line').forEach(function(element){
173 const qtyInput = element.querySelector("input.quantity"); 174 let quantity = (qtyInput ? parseInt(qtyInput.value) : parseInt(element.querySelector(".basket-line-quantity").textContent)); 175 176 177 items.push({ 178 item_name: element.querySelector("a.basket-product-link").textContent, 179 id: element.dataset.sku, //Added for Facebook pixel 180 item_id: element.dataset.sku, 181 price: element.dataset.price, 182 item_brand: element.dataset.brand, 183 item_category: element.dataset.category, 184 currency: 'GBP', 185 quantity: quantity 186 }); 187 }); 188 189 window.dataLayer.push({ 190 event: "beginCheckout", 191 ecommerce: { 192 items: items 193 } 194 }); 195 }, 196 197 addShippingInfo: function(shipping_option, callback) { 198 let items = []; 199 document.querySelectorAll(".basket-line").forEach(function(element){ 200 const qtyInput = element.querySelector("input.quantity"); 201 let quantity = (qtyInput ? parseInt(qtyInput.value) : parseInt(element.querySelector(".basket-line-quantity").textContent)); 202 203 items.push({ 204 item_name: element.querySelector("a.basket-product-link").textContent, 205 item_id: element.dataset.sku, 206 price: element.dataset.price, 207 item_brand: element.dataset.brand, 208 item_category: element.dataset.category, 209 quantity: quantity 210 }); 211 }); 212 213 window.dataLayer.push({ 214 event: "addShippingInfo", 215 ecommerce: { 216 shipping_tier: shipping_option, 217 items: items 218 }, 219 hitCallback: function() { 220 if(callback){ 221 callback(); 222 } 223 } 224 }); 225 226 /* 227 ** Failsafe to force callback in case of something going wrong 228 */ 229 setTimeout(function(){ 230 if(callback){ 231 callback(); 232 } 233 }, 3000); 234 } 235 236 }, 237 238 pushEvent: function(event_name, event_label = null, event_value = null){ 239 window.dataLayer.push({ 240 event : "genericEvent", 241 genericEventName : event_name, 242 genericEventLabel : event_label, 243 genericEventValue : event_value 244 }); 245 }, 246 247 pushConversion: { 248 appointment: { 249 bookingComplete: function(){ 250 window.dataLayer.push({ 251 event : "appointmentBookingComplete" 252 }); 253 } 254 }, 255 256 clickToCall: function(){ 257 window.dataLayer.push({ 258 event : "clickToCall" 259 }); 260 }, 261 262 createContactLead: function(userData){ 263 window.dataLayer.push({ 264 event : "contactLead", 265 // Values are pre-hashed (SHA-256) server-side; configure the Enhanced Conversions tag as "already hashed". 266 user_data : userData || undefined 267 }); 268 }, 269 270 createCallbackRequest: function(){ 271 window.dataLayer.push({ 272 event : "callbackRequest" 273 }); 274 }, 275 276 eVoucherCheckoutComplete: function(){ 277 window.dataLayer.push({ 278 "event" : "eVoucherCheckoutComplete" 279 }); 280 }, 281 282 newsletterSubscribe: function(){ 283 window.dataLayer.push({ 284 "event" : "newsletterSubscribe" 285 }); 286 }, 287 288 preownedAlertsSubscribe: function(){ 289 window.dataLayer.push({ 290 "event" : "preownedAlertsSubscribe" 291 }); 292 }, 293 294 search : function(search_term){ 295 window.dataLayer.push({ 296 "event" : "search", 297 "searchTerm" : search_term 298 }); 299 } 300 301 302 }, 303 304 Adwords: { 305 productImpression: function(){ 306 window.dataLayer.push({ 307 event: "AWRemarketingProductImpression", 308 ecomm_prodid: document.getElementById('sku').value, 309 ecomm_totalvalue: document.getElementById("product-container").dataset.price, 310 ecomm_pagetype: "product" 311 }); 312 } 313 } 314};
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.