What are our customers doing with their raw data destinations? 

Late last year, we were interested to learn what customers were building on top of our streaming webhooks and S3 connections. One name came up over and over again: AWS Lambda. AWS Lambda allows customers to write their own transformations and destination enhancements at a low cost and with little operational overhead. 

And we knew we had a chance to make it even easier. 

Today, we’re excited to announce the launch of our AWS Lambda Destination. Now customers can use our AWS Lambda Destination to execute custom, serverless code based on any call from Segment, like track() and identify() calls. 

The code you run on AWS Lambda (a “Lambda function”) can unlock endless new use cases for your business, and we’re excited to see what you build with it. 

What you can do with Segment + AWS Lambda

With AWS Lambda and Segment, you get the power of Customer Data Infrastructure and the flexibility to run code without provisioning or managing servers. Here are some of the ways customers are combining Segment events with AWS Lambda today:

  • Enrich events via internal + external data stores: Decorate your events with new data from the Clearbit API, snag product metadata of a productId, or fetch a required identity off the Personas Profile API.

  • Run advanced transforms: We understand there’s no one-size-fits-all when it comes to transforming your events. Merge property values to event names in Intercom or drop unnecessary fields from events. 

  • Customize existing integrations: Edit or augment existing integrations in our Catalog to better solve your business problems. If you can code it, you can ship it!

  • Build your own integrations: Want to send data to an integration we don’t support today? Just wire up the mapping you need in your Lambda and watch the events roll in!

One Solution, Endless Possibilities

Lambda functions are incredibly powerful, but often setting up, piping data in, and monitoring these functions come at a cost. Segment’s goal is to allow our customers to unlock powerful use cases, without having to spend a bunch of time configuring or debugging.

Our customer Mode Analytics, a data analytics platform, has wired up a system using Lambda to perform their own custom transformations.

AWS Lambda and Segment is a great combination. We collect and centralize our customer data with Segment, and AWS Lambda makes those events immediately actionable by processing, transforming, and sending them to marketing, support, and alerting tools we use every day.

-Benn Stancil, Chief Analytics Officer at Mode

Getting Started

Getting started with Segment and AWS Lambda is as easy as 1, 2, 3…

  1. Create your Lambda - In AWS (or using tools like Up), deploy your Lambda and create your IAM role.

  2. Point Segment at your Lambda - In your Lambda Destination settings, fill in the ARNs for your Lambda and an IAM role with invoke permissions.

  3. Start sending data - Enable your Destination and start enjoying the freedom to control your data’s destiny.

Want to try it out yourself? Here’s an example for a destination we don’t currently support in our catalog, Banjo Analytics. In less than 25 lines of code you’ll have data flowing.

import { Track, OrderCompleted } from '../../src/facade/events';
import { Success, ValidationError } from '../../src/responses'

interface Settings {}

export class BanjoAnalytics extends Integration {
  constructor(public settings: Settings) {
    super()
    this.subscribe<OrderCompleted>('Order Completed', this.orderCompleted)
  }
  async track(event: Track) {
    if (!event.userId) {
      return new ValidationError('UserId is a required property of all track events')
    }
    console.log(event.event)
    return new Success()
  }

  async orderCompleted(event: OrderCompleted) {
    console.log(event.properties.revenue)
    return new Success()
  }
}

You can find the full example, or add your own, in our Lambda Recipes repo on GitHub. 

Ready to try out AWS Lambda? Request a demo today or if you’re already a Segment customer, check out our docs and log in to your workspace to get started.