1$(function () { 2 var getPaymentType = function (order) { 3 var trans = order.Transactions; 4 if (trans && trans.length) { 5 var tran = trans[0]; 6 if (tran) { 7 var payment = tran.Payment; 8 if (payment) { 9 return payment.Type; 10 } 11 } 12 } 13 return ''; 14 } 15 , secure = Boolean(window.location.protocol.indexOf('https') === 0) 16 , pathName = window.location.pathname 17 ; 18 switch (pathName) { 19 case '/checkout/email/': 20 case '/checkout/print/': 21 case '/checkout/success/': { 22 break; 23 } 24 default: { 25 var gaLoaded = false; 26 $(document).ajaxSuccess(function (e, req, opts, data) { 27 if (!gaLoaded && secure) { 28 if (data['class'] == 'checkout') { 29 gaLoaded = true; 30 var cart = data.Cart 31 , order = data.Order 32 , paymentType = getPaymentType(order) 33 , action = { 34 'checkout_option': paymentType 35 , 'checkout_step': 1 36 , 'currency': 'USD' 37 } 38 ; 39 40 switch (pathName) { 41 case '/checkout/shipping/': { 42 if (paymentType == 'CreditCard') { 43 action['checkout_step'] = 2; 44 } 45 else if (paymentType == 'PayPal') { 46 action['checkout_step'] = 3; 47 } 48 break; 49 } 50 case '/checkout/review/': { 51 if (paymentType == 'CreditCard') { 52 action['checkout_step'] = 4; 53 } 54 else if (paymentType == 'PayPal') { 55 action['checkout_step'] = 5; 56 } 57 break; 58 } 59 } 60 61 try { 62 var cartItems = cart.Items.slice(0); 63 for (var i = 0; i < cartItems.length; i++) { 64 var cartItem = cartItems[i]; 65 cartItems[i] = { 66 'id': cartItem.Id 67 , 'category': cartItem.ItemType 68 , 'name': cartItem.ItemType 69 , 'price': cartItem.Price 70 , 'quantity': cartItem.Quantity 71 }; 72 } 73 74 action['items'] = cartItems; 75 76 gtag('event', 'checkout_progress', action); 77 } 78 catch (ex) { 79 } 80 } 81 } 82 }); 83 break; 84 } 85 } 86})
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.