1window.onload = function() { 2 const urlParams = new URLSearchParams(window.location.search); 3 const fbclid = urlParams.get('fbclid'); 4 5 let cart_data = {}; 6 let cart_products = []; 7 8 const dataLayerProducts = window.dataLayer?.[0]?.ecommerce?.checkout?.products || []; 9 10 document.querySelectorAll('.page-content .items_cart').forEach((item, index) => { 11 let productDetails = {}; 12 13 if (dataLayerProducts[index]) { 14 productDetails.id = dataLayerProducts[index].id ?? null; 15 productDetails.product_category = dataLayerProducts[index].category ?? null; 16 } 17 18 try { 19 let productName = item.querySelector('.cart_product_name').innerText.trim(); 20 productDetails.name = productName; 21 22 let rawLocation = item.querySelector('.cart_product_location').innerText.trim(); 23 24 if (rawLocation.includes('Check-in: ')) { 25 let detailsArray = rawLocation.split('\n'); 26 27 productDetails.checkIn = detailsArray[0].replace('Check-in: ', '').trim(); 28 productDetails.checkOut = detailsArray[1].replace('Check-out: ', '').trim(); 29 productDetails.roomDetails = detailsArray[2].trim(); 30 productDetails.lengthOfStay = detailsArray[3].replace('Length of Stay: ', '').trim(); 31 32 productDetails.subtotal = item.querySelector('.tick_list .woocommerce-Price-amount').innerText.trim(); 33 productDetails.total = item.querySelector('.iproduct_subtotal .woocommerce-Price-amount').innerText.trim(); 34 } else { 35 let detailsLocationArray = rawLocation.split(','); 36 37 productDetails.product_location = detailsLocationArray[0].trim(); 38 productDetails.product_date = detailsLocationArray[detailsLocationArray.length - 3].trim() + ', ' + detailsLocationArray[detailsLocationArray.length - 2].trim(); 39 productDetails.product_time = detailsLocationArray[detailsLocationArray.length - 1].trim(); 40 41 let tickets = []; 42 item.querySelectorAll('.tick_list .woocommerce-Price-amount').forEach((item2) => { 43 let ticketInfo = item2.previousSibling.textContent.trim(); 44 let qty = 1; 45 46 if (!ticketInfo.includes(', Seat ')) { 47 let ticketInfoArray = ticketInfo.split(/\s\s\s\s\s\s\s\s\s\s\s/g); 48 ticketInfo = ticketInfoArray[0]; 49 qty = ticketInfoArray[1]?.split(' ')[0] || 1; 50 } 51 52 let price = item2.innerText.replace('$', '').trim(); 53 54 tickets.push({ 55 ticket_name: ticketInfo, 56 ticket_qty: qty, 57 ticket_price: parseFloat(price), 58 }); 59 }); 60 61 productDetails.tickets = tickets; 62 productDetails.product_subtotal = parseFloat(item.querySelector('.iproduct_subtotal .woocommerce-Price-amount').innerText.replace('$', '').trim()); 63 } 64 65 cart_products.push(productDetails); 66 } catch (error) { 67 console.error('Error processing cart item:', error); 68 } 69 }); 70 71 const serviceFeeElement = document.querySelector('.fee-2Service.fee.per.ticket .woocommerce-Price-amount'); 72 const serviceFee = serviceFeeElement ? parseFloat(serviceFeeElement.innerText.replace('$', '').trim()) : null; 73 74 cart_data = { 75 cart_products, 76 service_fee_per_ticket: serviceFee, 77 total_cart_value: window.dataLayer?.[0]?.ecomm_totalvalue ?? "", 78 currency: window.dataLayer?.[0]?.ecommerce?.currencyCode ?? "", 79 pagetype: window.dataLayer?.[0]?.ecomm_pagetype ?? "", 80 hostname: window.location.hostname ?? "", 81 directory: window.location.pathname.split('/').slice(0, -1).join('/') ?? "", 82 path: window.location.pathname ?? "", 83 referrer: document.referrer ?? "", 84 search: window.location.search ?? "", 85 title: document.title ?? "", 86 fbc: getFBC(fbclid), 87 fbp: getFBP(),
88 ...Object.fromEntries(urlParams.entries()), // Extract UTM parameters 89 url: window.location.href ?? "", 90 ip_address: window.dataLayer?.[0]?.user?.ip_address ?? "", 91 user_country: window.dataLayer?.[0]?.user?.country ?? "", 92 user_region: window.dataLayer?.[0]?.user?.region ?? "", 93 user_city: window.dataLayer?.[0]?.user?.city ?? "", 94 user_postal: window.dataLayer?.[0]?.user?.postal ?? "", 95 events_uuid: window.app?.uuid ?? "", 96 user_or_session_id: window.app?.user_or_session_id ?? "", 97 }; 98 99 trackViewCart(cart_data); 100 101}; 102 103async function trackViewCart(cart_data) { 104 105 const additionalParams = await getAdditionalParams() 106 107 if (typeof htevents !== 'undefined' && typeof htevents.track === 'function') { 108 htevents.track('View cart', removeEmptyProperties({...cart_data, ...additionalParams})); 109 } else { 110 console.error('htevents.track is not defined'); 111 } 112}
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.