1dataLayer = []; 2 3var MEcommerce = { 4 data: {}, 5 6 init: function() 7 { 8 9 }, 10 11 measuringProductImpressions: function() 12 { 13 var products = []; 14 $.each(MEcommerce.data.products, function( index, value ) 15 { 16 products.push(value); 17 }); 18 19 dataLayer.push( 20 { 21 'ecommerce': { 22 'currencyCode': MEcommerce.data.currencyCode, 23 'impressions': products 24 } 25 }); 26 }, 27 28 measuringProductClicks: function(item, redirect) 29 { 30 var code = $(item).attr('product-code'); 31 var url = $(item).attr('link'); 32 33 var product = MEcommerce.data.products[code]; 34 dataLayer.push( 35 { 36 'event': 'productClick', 37 'ecommerce': 38 { 39 'click': 40 { 41 'actionField': {'list': 'Product Select Page'}, 42 'products': [product] 43 } 44 }, 45 'eventCallback': function() 46 { 47 if(redirect) 48 { 49 document.location = encodeURI(url); 50 } 51 } 52 }); 53 54 if(redirect) 55 { 56 document.location = encodeURI(url); 57 } 58 }, 59 60 measuringViewsOfProductDetails: function() 61 { 62 var product = MEcommerce.data.products[0]; 63 dataLayer.push({ 64 'ecommerce': 65 { 66 'detail': 67 { 68 'actionField': {'list': 'Product Select Page'}, 69 'products': [product] 70 } 71 } 72 }); 73 }, 74 75 measuringAddToCart: function(product) 76 { 77 dataLayer.push( 78 { 79 'event': 'addToCart', 80 'ecommerce': { 81 'currencyCode': MEcommerce.data.currencyCode, 82 'add': { 83 products: [product] 84 } 85 } 86 }); 87 }, 88 89 measuringRemoveFromCart: function(product) 90 { 91 dataLayer.push( 92 { 93 'event': 'removeFromCart', 94 'ecommerce': { 95 'remove': { 96 products: [product] 97 } 98 } 99 }); 100 }, 101 102 measuringCheckout: function() 103 { 104 dataLayer.push( 105 { 106 'event': 'checkout', 107 'ecommerce': { 108 'checkout': { 109 'actionField': {'step': 1, 'option': 'Checkout'}, 110 'products': MEcommerce.data.products 111 } 112 } 113 }); 114 }, 115 116 measuringPurchases: function() 117 { 118 dataLayer.push( 119 { 120 'ecommerce': { 121 'purchase': { 122 'actionField': MEcommerce.data.order, 123 'products': MEcommerce.data.products, 124 'value': MEcommerce.data.order.revenue -MEcommerce.data.order.tax - MEcommerce.data.order.shipping, 125 } 126 } 127 }); 128 } 129}; 130 131MEcommerce.init();
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.