This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Handler function, invoked on every 'Audience Entered' and 'Audience Exited' event (i.e. track calls sent outbound from Personas with audience data) | |
| // Invoke function on Track Events. Define Vars | |
| async function onTrack(event, settings) { | |
| var userId = event.userId; | |
| var email = event.traits.email; | |
| var personasAudienceEvent = event.event; // This will resolve to 'Audience Entered' or 'Audience Exited' | |
| var audienceKey = event.properties.audience_key; | |
| var kochavaEndpoint = 'http://control.kochava.com/track/json'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Learn more about source functions API at | |
| // https://segment.com/docs/connections/sources/source-functions | |
| /** | |
| * Handle incoming HTTP request | |
| * | |
| * @param {FunctionRequest} request | |
| * @param {FunctionSettings} settings | |
| */ | |
| async function onRequest(request) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function onTrack(event, settings) { | |
| const endpoint = settings.streamingEndpoint; | |
| let response; | |
| //only sending event if it includes userID. Will not send event if the event only includes anonymousID | |
| if (event.userId) { | |
| let body = { | |
| header: { | |
| schemaRef: { | |
| id: settings.schemaId, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Handler function, invoked on every identify event (i.e. identify calls sent outbound from Personas with audience data) | |
| // Step 1. Invoke function on identify event. Save userId & email to js vars | |
| async function onIdentify(event, settings) { | |
| var traits = event.traits || {}; | |
| var email = traits.email; | |
| var userId = event.userId; | |
| var anonymousId = event.anonymousId; | |
| // Save Clearbit Reveal fields to variables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Learn more about destination functions API at | |
| // https://segment.com/docs/connections/destinations/destination-functions | |
| /** | |
| * Handle track event | |
| * @param {SegmentTrackEvent} event | |
| * @param {FunctionSettings} settings | |
| */ | |
| async function onTrack(event, settings) { | |
| // Learn more at https://segment.com/docs/connections/spec/track/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Handler function, invoked on every identify event (i.e. identify calls sent outbound from Personas with audience data) | |
| // Step 1. Invoke function on identify event. Save userId & email to js vars | |
| async function onIdentify(event, settings) { | |
| var traits = event.traits || {}; | |
| var email = traits.email; | |
| var userId = traits.userId; | |
| // Step 2. Make HTTP request to Profile API with email | |
| // You can use userId value instead of email as a lookup field. In this case, insert "user_id:${userId_variable_name}" in Profile API URL instead of "email:${email_variable_name}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Handler function, invoked on every identify event | |
| // Argument: event = event payload, settings = function settings, as of Jan 2020 it provides access to API Key value. | |
| // Step 1. Invoke func on identify event | |
| async function onIdentify(event, settings) { | |
| event.traits = event.traits || {}; | |
| var ce_email = event.traits.email; // Step 2. Pick up email from 'traits' obj of the incoming event | |
| var ce_user_id = event.userId; // Pick up CE userId from the incoming event | |
| var isQualified = event.traits.is_qualified; // Should be true or false. Set by SQL Trait | |
| // Step 3. Make HTTP request to Profile API with the email from previous step |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Step 1. Invoke func on incoming identify event. onIdentify is a handler function, invoked on every identify event | |
| // Argument: event = event payload, settings = function settings, as of Jan 2020 settings provides access to API Key values. | |
| // It is recommended you store these in Function’s Settings and reference settings.<field_name> in the function below | |
| async function onIdentify(event, settings) { | |
| // Define variables for Iterable Marketing Project access keys and/or IDs and Personas specific keys | |
| const iterableMpId = settings.iterableMpId; | |
| const iterableMpKey = settings.iterableMPKey; | |
| const iterableMpEndpoint = settings.iterableMpEndpoint; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Step 1. Invoke func on incoming identify event. onIdentify is a handler function, invoked on every identify event | |
| // Argument: event = event payload, settings = function settings, as of Jan 2020 settings provides access to API Key values. | |
| // It is recommended you store these in Function’s Settings and reference settings.<field_name> in the function below | |
| async function onIdentify(event, settings) { | |
| // Define variables for CIO and Personas specific keys | |
| const cioSiteId = settings.cioSiteId; | |
| const cioApiKey = settings.cioApiKey; | |
| const cioEndpoint = settings.cioTrackingEndpoint; // https://customer.io/docs/api/ | |
| const personasSpaceId = settings.personasSpaceId; | |
| const personasAccessSecret = settings.personasAccessSecret; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function onRequest(request, settings) { | |
| const body = await request.json(); | |
| console.log(body); // For testing | |
| const mapping = | |
| // StockX team to verify that these mappings are accurate | |
| [ | |
| { oldVal: 'Product Tile', newVal: 'Product Tile Clicked' }, | |
| { oldVal: 'Buy or Bid', newVal: 'Buy or Bid Button Clicked' }, | |
| { oldVal: 'Sell or Ask', newVal: 'Sell or Ask Button Clicked' }, | |
| { oldVal: 'Toggle', newVal: 'Checkout Flow Toggle Clicked' }, |