diff --git a/packages/analytics-js-integrations/src/integrations/SnapPixel/browser.js b/packages/analytics-js-integrations/src/integrations/SnapPixel/browser.js index 0b4415e112..608824a3f9 100644 --- a/packages/analytics-js-integrations/src/integrations/SnapPixel/browser.js +++ b/packages/analytics-js-integrations/src/integrations/SnapPixel/browser.js @@ -13,6 +13,7 @@ import { } from '../../utils/commonUtils'; import { ecommEventPayload, eventPayload, getUserEmailAndPhone, sendEvent } from './util'; import { loadNativeSdk } from './nativeSdkLoader'; +import { getDefinedTraits } from '@rudderstack/analytics-js-integrations/utils/utils'; const logger = new Logger(DISPLAY_NAME); @@ -99,6 +100,8 @@ class SnapPixel { const userEmail = get(message, 'context.traits.email'); const userPhoneNumber = get(message, 'context.traits.phone'); const ipAddress = get(message, 'context.ip') || get(message, 'request_ip'); + const age = get(message, 'context.traits.age'); + const { firstName, lastName, postalCode, country, city, state } = getDefinedTraits(message); let payload = {}; if (!userEmail && !userPhoneNumber && !ipAddress) { @@ -109,7 +112,17 @@ class SnapPixel { } payload = getUserEmailAndPhone(this.hashMethod, userEmail, userPhoneNumber); - payload = { ...payload, ip_address: ipAddress }; + payload = { + ...payload, + ip_address: ipAddress, + firstname: firstName, + lastname: lastName, + age, + geo_city: city, + geo_region: state, + geo_postal_code: postalCode, + geo_country: country, + }; payload = removeUndefinedAndNullValues(payload); window.snaptr('init', this.pixelId, payload); diff --git a/packages/analytics-js-integrations/src/integrations/SpotifyPixel/browser.js b/packages/analytics-js-integrations/src/integrations/SpotifyPixel/browser.js index e00e60180b..8ec3070dce 100644 --- a/packages/analytics-js-integrations/src/integrations/SpotifyPixel/browser.js +++ b/packages/analytics-js-integrations/src/integrations/SpotifyPixel/browser.js @@ -16,7 +16,7 @@ import { ADD_TO_CART_EVENT, CHECK_OUT_EVENT, LEAD_EVENT, -} from '@rudderstack/analytics-js-common/constants/integrations/CommonIntegrationsConstant/constants' +} from '@rudderstack/analytics-js-common/constants/integrations/CommonIntegrationsConstant/constants'; import { ScriptLoader } from '@rudderstack/analytics-js-common/v1.1/utils/ScriptLoader'; import Logger from '../../utils/logger'; import { diff --git a/packages/analytics-js-integrations/src/utils/utils.js b/packages/analytics-js-integrations/src/utils/utils.js index ce4e9910f5..c287833699 100644 --- a/packages/analytics-js-integrations/src/utils/utils.js +++ b/packages/analytics-js-integrations/src/utils/utils.js @@ -148,7 +148,7 @@ function recurse(cur, prop, result, visited = new Set()) { }; if (visited.has(cur)) { - res[prop] = "[Circular Reference]"; + res[prop] = '[Circular Reference]'; return result; } @@ -271,6 +271,13 @@ function getDefinedTraits(message) { get(message, 'context.traits.Country') || get(message, 'context.traits.address.country') || get(message, 'context.traits.address.Country'), + postalCode: + get(message, 'context.traits.postalCode') || + get(message, 'context.traits.postalcode') || + get(message, 'context.traits.postal_code') || + get(message, 'context.traits.address.postalCode') || + get(message, 'context.traits.address.postal_code') || + get(message, 'context.traits.address.postalcode'), }; if (!get(traitsValue, 'name') && get(traitsValue, 'firstName') && get(traitsValue, 'lastName')) {