top of page

Segment Functions : how to get integrated with any unsupported systems

Segment is one of many powerful CDPs existing on the market. For those of you that are not that familiar with the concept of a CDP - you can find a full article we wrote on the subject on our blog if you want more details - the principle is quite simple : connect your various sources of data (any systems you’d want to ingest data from) to any destinations where you’d want to activate it (be it for analytics, engagement, or any other purpose), while unifying into a customer 360 view by managing the identity resolution. In the case of Segment, you’ll find an already well-filled catalog of pre-built integrations that can be used right out of the box.


While having hundreds of existing integrations (and new ones being built and added all the time), it can happen that Segment doesn’t have the one you need for your system. Or, that your existing destination needs to be customised so much that the existing mapper functions are not able to handle it. That’s where Segment Functions can come into play.


Segment Functions can solve the issue above by integrating your tool with any unsupported systems (as long as the requirements we specify further in this article are met). Nothing brand new here, as Segment Functions have been launched a while ago, in 2019. However, the feature is not always known or understood properly, hence why this article might be helpful for you to discover its potential.


On top of explaining what these functions are and how to use them, we’ll also provide some real-life use cases to help you understand the power and benefits of the feature for your business.


What are Segment functions ?


The main purpose of Segment Functions is simple: bridge the gap between some tools in your stack. It can be used, either to bring data into Segment ( = Source Functions) from systems that are not supported out of the box (read, for which there is no existing integration), either to send data out of segment ( = Destination Functions) to destinations that are not supported out of the box.


Put simply, a Segment function is an AWS lambda function directly integrated and fully-managed directly into the Segment interface.


When we say that Functions can help you integrate with any unsupported systems, it’s important to specify that there are conditions that need to be met by these systems for this to be true :


  1. If the system is the source, it needs to be able to create automation when an action occurs (basically, triggering an event).

  2. Also, the system needs to be able to have those automation send the data to another system (basically, POST the data ; aka Webhook capabilities)

  3. If the system is the destination, it needs to be able to receive the payloads (aka API endpoint).


If the above is true for the system you want to integrate, then you should be able to get the data into Segment.


Let’s now look into more details on the differences between Source Functions and Destination Functions with an example.


Source Functions


Source functions are an interface that can be used as an entry point from systems that are not natively supported by Segment. The principle is straightforward:

  • Your source system sends a payload (from a webhook) to the source function (to an endpoint) with the data available.

  • The source function receives the payload and handles it doing the necessary manipulation to make it match with Segments data model requirements (transforming the payload into track / identify / page / group calls).

  • In the process you could also do any extra transformations or enrichment you’d want (ie. calling an API to enrich the payload with extra data).


Source: segment.com documentation on sending data from unsupported system using source functions


Find below an example of Source Function snippet of code :



Destination Functions


Destination Functions on the other hand are meant to handle Segment’s regular methods and output it to match with any of your unsupported destinations requirements (often sending that transformed data to an API endpoint). The principle is again quite straightforward:

  • You have various events / messages coming into segment from various sources.

  • In the Destination Function, you define the handlers for each message type from the Segment spec that you want to map to your unsupported destination (track, page, Identify, …).

  • For each of these handlers, you build the payload that needs to be sent according to your destination’s requirements, and use a ‘POST’ method to send it to the endpoint of your choice.

  • In the process you could also do any extra transformations or enrichment you’d want (ie. calling an API to enrich the payload with extra data).


Source: segment.com documentation on forwarding data to unsupported system using destination functions


Find below an example of Destination Function snippet of code :



What can you do with Functions ? Some use cases examples


Let’s have a look at a couple of examples of how Segment functions can help your business.


Use Case #1 - Stripe subscription events


Stripe is a well known online payment system used by thousands of businesses to invoice, pay and receive payments. However there is no built-in integration to ingest events from Stripe in Segment directly - or at least not one that allows you to have a real-time streaming of events happening in the platform sent directly to Segment.


The good news is that Stripe has Webhook capabilities that allow you to build a Source function to ingest events such as invoicing success, subscriptions created, trials coming to and end, … This unlocks a world of possibilities in terms of analysing or acting upon those events.


Use Case #2 - Zendesk tickets


Zendesk is one of the leading solutions in terms of tracking, prioritising and solving customer support tickets. This is definitely valuable data for you to understand your users behavior, but once again - there is no built-in integration that allows you to gather this information in Segment (at least, no information in regards with Tickets creation)


On the other hand, Zendesk offers a wide variety of APIs and Webhooks that can be leveraged together with Segment functions in order to make it possible for you to (1) ingest Ticket Creation (or any other interaction) data into Segment thanks to a Source Function, or (2) create Tickets in Zendesk directly based on Segment events thanks to a Destination Function.


As you’d understand from all of the above - the range of possible integrations with Segment goes much further than the catalog of built-in ones.


Want some more inspiration? Have a look at the GitHub Segment Functions Repo, or get in touch with us!



bottom of page