diff --git a/src/v0/destinations/facebook_pixel/config.js b/src/v0/destinations/facebook_pixel/config.js index 99c3c70b2d..f5f895aea9 100644 --- a/src/v0/destinations/facebook_pixel/config.js +++ b/src/v0/destinations/facebook_pixel/config.js @@ -95,6 +95,7 @@ const OTHER_STANDARD_EVENTS = [ ]; const FB_PIXEL_DEFAULT_EXCLUSION = ['opt_out', 'event_id', 'action_source']; +const FB_PIXEL_CUSTOM_DATA_EXCLUDE_FLATTENING = ['content_ids', 'contents']; const STANDARD_ECOMM_EVENTS_TYPE = [ CONFIG_CATEGORIES.PRODUCT_LIST_VIEWED.type, CONFIG_CATEGORIES.PRODUCT_VIEWED.type, @@ -109,6 +110,7 @@ module.exports = { MAPPING_CONFIG, ACTION_SOURCES_VALUES, FB_PIXEL_DEFAULT_EXCLUSION, + FB_PIXEL_CUSTOM_DATA_EXCLUDE_FLATTENING, STANDARD_ECOMM_EVENTS_TYPE, OTHER_STANDARD_EVENTS, DESTINATION: 'FACEBOOK_PIXEL', diff --git a/src/v0/destinations/facebook_pixel/transform.js b/src/v0/destinations/facebook_pixel/transform.js index 02c416cfde..ba85d4e794 100644 --- a/src/v0/destinations/facebook_pixel/transform.js +++ b/src/v0/destinations/facebook_pixel/transform.js @@ -6,6 +6,7 @@ const { CONFIG_CATEGORIES, MAPPING_CONFIG, FB_PIXEL_DEFAULT_EXCLUSION, + FB_PIXEL_CUSTOM_DATA_EXCLUDE_FLATTENING, STANDARD_ECOMM_EVENTS_TYPE, } = require('./config'); const { EventType } = require('../../../constants'); @@ -85,7 +86,12 @@ const responseBuilderSimple = (message, category, destination) => { if (category.type !== 'identify') { customData = flattenJson( - extractCustomFields(message, customData, ['properties'], FB_PIXEL_DEFAULT_EXCLUSION), + extractCustomFields( + message, + customData, + ['properties'], + [...FB_PIXEL_DEFAULT_EXCLUSION, ...FB_PIXEL_CUSTOM_DATA_EXCLUDE_FLATTENING], + ), ); if (standardPageCall && category.type === 'page') { category.standard = true; @@ -124,6 +130,11 @@ const responseBuilderSimple = (message, category, destination) => { } if (type === 'simple track') { customData.value = message.properties?.revenue; + FB_PIXEL_CUSTOM_DATA_EXCLUDE_FLATTENING.forEach((customDataParameter) => { + if (message.properties?.[customDataParameter]) { + customData[customDataParameter] = message.properties[customDataParameter]; + } + }); delete customData.revenue; } }