Skip to main content

Segment Source Functions

Segment Source Functions are the primary method for delivering recommendations to connected Segment accounts.

Read more about Segment Source Functions

Segment Source channels are not yet supported
Creating a connection
  • For a recommendation channel to be valid, it must be associated with an existing Segment connection.

Creating a Segment Source Function Channel

In Cherry, click Promotions on the sidebar, then Channels and then click on Create New. Next, choose which Segment Integrated System you wish to associate the channel with. After creating the channel, go to the Configure tab. In the Endpoint field, enter the HTTP/HTTPS location of the webhook URL then save.

Screenshot of where to configure channel endpoint

This webhook will be called every time the campaign is invoked.

Assocating with Campaign

In the campaign tabs, click on Delivery.

Screenshot of where to find the Delivery tab

Next, click Add Channel and choose which channel you wish to associate the campaign with.

Configure the Segment code

In Segment, you'll need to write some Javascript to transform the incoming recommendation. The sample below produces a Segment TRACK event with the top recommended item.

* Handle incoming HTTP request
* @param {FunctionRequest} request
* @param {FunctionSettings} settings
async function onRequest(request, settings) {
const body = request.json();
// See
event: "Recommendation Produced",
// assumes the commonUserId is the same userId as Segment userId
userId: body.customer.commonId,
properties: {
recommendedItem: body.scoredItems[0].itemCommonId,