// Run after dataLayer events are pushed window.addEventListener('DOMContentLoaded', function() { // Observe pushes to the dataLayer const originalPush = window.dataLayer.push;window.dataLayer.push = function(event) { // Only fix add_to_cart or purchase events if(event.event === 'add_to_cart' || event.event === 'purchase') {// Fix eventModel prices (Site Kit) if(event.eventModel && event.eventModel.items){ event.eventModel.items.forEach(function(item){ // Remove commas and convert to float item.price = parseFloat(String(item.price).replace(/,/g,'')); }); // Fix overall eventModel value if exists if(event.eventModel.value) { event.eventModel.value = parseFloat(String(event.eventModel.value).replace(/,/g,'')); } }// Fix ecommerce object prices (if present) if(event.ecommerce && event.ecommerce.items){ event.ecommerce.items.forEach(function(item){ item.price = parseFloat(String(item.price).replace(/,/g,'')); }); if(event.ecommerce.value) { event.ecommerce.value = parseFloat(String(event.ecommerce.value).replace(/,/g,'')); } } }// Call original push return originalPush.apply(window.dataLayer, arguments); }; });

IdeaMart Online Shop in Pakistan

tv remote cover

Scroll to Top