<!– customHTML on sale page AND event=gtm.dom ready –>

<script>

// Settings

var myActionString = “purchase”; // promo_click > detail > add | remove > checkout | checkout_option >>> purchase | refund

var myStepInt = 6; // 1-6

var myStepOptionalNameString = “complete”; // checkout > login > delivery > billing > payments > complete

 

// Cannot execute loops within an array declaration.

// Thus – first create the products array before pushing it into dataLayer.

 

var eCommProductsENHANCED = [],

currProduct, i, ii;

for (i = 0, ii = {{dataLayer.transactionProducts}}.length; i < ii; i += 1) {

currProduct = {{dataLayer.transactionProducts}}[i];

eCommProductsENHANCED.push({

“id”: currProduct.sku, // SKU

“sku”: currProduct.sku,

“name”: currProduct.name,

“price”: currProduct.price, // Includes Tax: 100+tax = 120.00

“category”: currProduct.category,

“quantity”: currProduct.quantity

//”brand”: currProduct.brand,

//”variant”: currProduct.variant,

//”coupon”: currProduct.coupon

});

}

 

// Now declare Ecommerce payment dataLayer variables

window.dataLayer = window.dataLayer || [];

dataLayer.push({

//Transaction level mapping

“ecommerce.purchase.actionField.step”: myStepInt,

“ecommerce.purchase.actionField.option”: myStepOptionalNameString,

“ecommerce.currencyCode”: “{{dataLayer.transactionCurrency}}”,

“ecommerce.purchase.actionField.id”: “{{dataLayer.transactionId}}”,

“ecommerce.purchase.actionField.affiliation”: “{{dataLayer.transactionAffiliation}}”, // optional

“ecommerce.purchase.actionField.revenue”: {{dataLayer.transactionTotal}},

“ecommerce.purchase.actionField.tax”: {{dataLayer.transactionTax}}, // 250 * (1-(100%/120%))

“ecommerce.purchase.actionField.shipping”: {{dataLayer.transactionShipping}},// Includes Tax: 8.33 + tax = 10.00

//”ecommerce.purchase.actionField.shippingMethod”: dataLayer.transactionShippingMethod,// optional

//”ecommerce.purchase.actionField.date”: dataLayer.transactionDate, // optional

//”ecommerce.purchase.actionField.coupon”: dataLayer.transactionCoupon, // optional

//”ecommerce.purchase.actionField.couponDiscount”: dataLayer.transactionCouponDiscount, // optional

//”ecommerce.purchase.actionField.paymentType”: dataLayer.transactionPaymentType, // optional

//”ecommerce.purchase.actionField.type”: dataLayer.transactionType, // optional

//”ecommerce.purchase.actionField.subTotalIncludeTax”: dataLayer.transactionSubTotalIncludeTax,

 

//Item level mapping

“ecommerce.products”: eCommProductsENHANCED, // Trigger Loop array above

//Trigger Transaction

“event”: “customhtml_enhanced_ecommerce_mapping_loaded”

});

</script>

0117 3361103