checkoutEmail: null,
currency: "INR",
pageType: "Product",
ecommerce: {
checkout: {
actionField: {step: 1},
products: [
{
id: "7930939080932",
name: "Flexnest Turbo Massage Gun - Black",
quantity: 1,
price: 2499,
variant: "43824830382308",
currency: "INR"
},
{
id: "7502058782948",
name: "Flexnest Ultra Massage Gun - Hot/Cold Head",
quantity: 2,
price: 2999,
variant: "43680763412708",
currency: "INR"
},
{
id: "5676038291619",
name: "The Flexikettle - 20lb",
quantity: 1,
price: 6999,
variant: "43299358605540",
currency: "INR"
},
{
id: "7502058782948",
name: "Flexnest Ultra Massage Gun - Massage Gun",
quantity: 5,
price: 4999,
variant: "43680763347172",
currency: "INR"
},
{
id: "5675742396579",
name: "The Flexibell Stand",
quantity: 1,
price: 7999,
variant: "36209892950179",
currency: "INR"
}
]
}
},
eventAction: "Widget-Impressions",
eventCategory: "Widget",
merchantName: "PreEnrolMerchant",
widgeturl: "https://www.theflexnest.com",
pdpPrice: 4999
}
function(){
var productList={{ecommerce}}.checkout.products;
var totalAmount=0;
for(var i=0;i<productList.length;i++)
{
totalAmount+=(productList[i].quantity)*(parseFloat(productList[i].price));
}
return totalAmount;
}
Google Tag Manager custom javascript variable to calculate the total cart value - Stack Overflow