diff --git a/cartridges/int_klaviyo_sfra/cartridge/scripts/utils/klaviyo/contextValues.js b/cartridges/int_klaviyo_sfra/cartridge/scripts/utils/klaviyo/contextValues.js index 72fa8f89..5560f6d9 100644 --- a/cartridges/int_klaviyo_sfra/cartridge/scripts/utils/klaviyo/contextValues.js +++ b/cartridges/int_klaviyo_sfra/cartridge/scripts/utils/klaviyo/contextValues.js @@ -4,7 +4,13 @@ var contexts = { "checkoutShipping" ], placedOrder: [ - "orderconfirmation" + "orderConfirmation" + ], + categoryViewed: [ + "search" + ], + viewedProduct: [ + "product" ] } diff --git a/cartridges/int_klaviyo_sfra/cartridge/scripts/utils/klaviyo/klaviyoDataLayer.js b/cartridges/int_klaviyo_sfra/cartridge/scripts/utils/klaviyo/klaviyoDataLayer.js index 0e5e748a..e811988e 100644 --- a/cartridges/int_klaviyo_sfra/cartridge/scripts/utils/klaviyo/klaviyoDataLayer.js +++ b/cartridges/int_klaviyo_sfra/cartridge/scripts/utils/klaviyo/klaviyoDataLayer.js @@ -56,16 +56,15 @@ var buildDataLayer = function () { KlaviyoUtils.prepareOrderConfirmationEventForKlaviyo(currentOrder); } - // Viewed Product event - if (!empty(pageProductID.rawValue)) { + if (contexts.viewedProduct.indexOf(pageContext) > -1) { viewedProduct = productMgr.getProduct(pageProductID); KlaviyoUtils = require('*/cartridge/scripts/utils/klaviyo/klaviyoUtils'); klData = KlaviyoUtils.prepareViewedProductEventData(pageProductID, viewedProduct); } // Category Viewed event - if (!empty(pageCategoryId)) { + if (contexts.categoryViewed.indexOf(pageContext) > -1 && pageCategoryId) { klData.event = 'Viewed Category'; klData.pageCategoryId = pageCategoryId; }