Many successful brands — Facebook, Google, Amazon, Etsy, Pinterest, to name a few — have proven that custom ad platforms can drive billions of dollars and give them the capital to beat their competitors. These ad platforms nearly always tie together native ad units with first-party data targeting.
If you’d also like to monetize and drive new revenue in this way, you’ll need a way to tie together your first-party data with your ad server. You can do that with Segment and Kevel by automatically pushing personas from Twilio Engage (formerly Segment Personas) directly to Kevel, which can then be targeted in a campaign.
This recipe specifically looks at how to connect Kevel with Segment, send Personas Audiences to Kevel as custom audiences, and then show them ads inside your own website or app.
Step 1: Connect Segment to Kevel
Start by connecting your Segment and Kevel accounts. You’ll need your Kevel network ID and API Key, which can be found in the Kevel UI.
From your Segment account, search for Kevel's Destination Integration and click "Configure Kevel".

Next, you'll need to connect your Segment Source with the Kevel Destination. Once you select a Source, it's time to configure your credentials. You will see an interface similar to this:

To get your API Key, log in to the Kevel app and navigate to "Settings" -> "API Keys" via the top navigation. You'll see all your API Keys listed there.
You can find your Network ID using the "Information" bubble next to your username in the top right corner of the Kevel app.

Step 2: Create an audience in Engage
This recipe assumes you have Segment installed and are tracking events tied to a specific User ID. From those events you can define a new audience definition in Engage. In this example, we’re creating an audience named “Influencer” based on their Twitter follower’s trait.

Once you’ve defined the audience rules, then connect the audience to the Kevel Destination. If Segment asks, it should use the Identify event for this connection.
Segment will send an event to Kevel’s UserDB for each member of the audience, and Kevel will record the audience as a UserDB interest.
Step 3: Create a custom targeting campaign in Kevel
Now, in your Kevel account create a new campaign and a flight, and in the flight use a custom targeting rule like the following example. Alternatively, you can also leverage Kevel’s Campaign APIs.

This custom targeting rule checks the UserDB record at time of ad request to see if the user has the “Influencer” interest. If so, then we know they fall into the “Influencer” audience, and the ad will be eligible to be served. Anyone outside of that audience would not receive this ad.
Step 4: Send Decision API requests containing User IDs and serve the ads
You also need to ensure you’re sending User IDs in the ad request for all API calls. This persistent user ID should correspond to the ID you gave to Segment for that user, and be sent as the key value in the `user` object in the Decision API request.
{
"placements": [
{
"divName": "homepage",
"networkId": 23,
"siteId": 667480,
"adTypes": [5],
"eventIds": [12,13,14]
}
],
"user" : {
"key": "ad39231daeb043f2a9610414f08394b5"
}
}
If Kevel’s system does identify a user as an Influencer, the campaign targeting these Influencers would be eligible to be shown. If that ad wins the auction, Kevel’s API response would include information about the ad, including image URL, tracking URLs, metadata, etc, and you would then insert the data directly into your backend system before the content loads for the user.

Wrapping up
Here’s what we’ve done in this recipe:
Connected Segment and Kevel
Defined an audience in Engage to identify Twitter influencers and inform Kevel’s UserDB
Created a promotional campaign in Kevel that will target only your Twitter influencer audience
Sent Kevel Decision API requests containing the UserKey
Getting started is easy
Start connecting your data with Segment.