window.dataLayer = window.dataLayer || []; // Function to update or set pagetype in the dataLayer function updatePagetype(value) { var existingData = window.dataLayer.find(function(item) { return item.hasOwnProperty('pagetype'); }); if (existingData) { // Update the existing pagetype value existingData.pagetype = value; } else { // Create a new data object with pagetype window.dataLayer.push({ pagetype: value }); } } // Call the function to update or set pagetype const requestType = window.shop_settings.request_type; updatePagetype(requestType);