Segment Integration

Segment makes it easy to send your data to Watsi (and lots of other integrations). Once you've tracked your data through their open source libraries they'll translate and route your data to Watsi in the format they understand.

The Watsi integration gives you the ability to create a trigger which will send a Watsi gift card to your users based on your Segment events!

Getting Started

First of all, make sure you have a Watsi account. Once you have an account, you must have access to this integration. To get access, please email Watsi at [email protected] with your account information, and we'll turn on this feature on for you.

Now we can go to the Segment settings page - you need to be logged in to view it - where you will see a few tabs:

  • Account Information - Here is where you can find your Api Auth Token and your email, the two necessary fields for enabling Watsi as a Segment integration (more on that below).
  • Activity Log - Here is where you will see a list of actions that Watsi has taken because of the integration. You will be able to keep track of successful triggers and also get insights as to any failures you might receive.
  • Segment Events - In this pane, you can create, edit, and delete your custom triggers that Watsi will attempt to send gift cards for.

Segment Events

1154

The Segment Events pane

Here you will see a list of events you have created triggers for. In this example, I have created a trigger for a Sign Up event that when read by Watsi will send a Gift Card to the recipient (presumably someone who signs up for your service) for $10. Let's add a new trigger for someone upgrading their accounts.

1142

Notice that Watsi can currently only create triggers based on Segment track calls. If you would like to expand on other Segment call types, let us know!

Finally, once I click Save, our trigger will be made.

1104

Voilá!

That's pretty much all there is to set up on the Watsi side of this. However, no gift cards are being sent yet! That's because we haven't turned on the Watsi Segment integration yet. Let's go to our Segment dashboard and look at the Watsi Integration:

1544

We're going to want to add our API Auth Token and email that we saw earlier and click on Enable Integration. Now things should be good to go. Let's talk about what the events should look like.

Track

When you call track, Segment will send the event to Watsi with the event name and properties you provide. For Watsi's integration, we accept any track event, but we only do something for the triggers you've set above. Let's say you named the event Sign Up

Sign Up

If you'd like to send a Watsi gift card to one of your customers, all you have to do is send us this track event along with the following properties:

property keydescription
nameThe name of the customer who will receive a gift card.
emailThe customer's email to send the gift card to.

Responses

If a gift card is successful, an empty HTTP 200 is returned, as Segment docs specify. This means your customer should receive a gift card to their email address!

Example Calls

Here's an example of a track call with most common fields removed and its response (an HTTP 200 OK):

{
  "type": "track",
  "event": "Send Gift Card",
  "properties": {
    "name": "Shigeru Miyamoto",
    "email": "[email protected]"
  }
}
{}

Here's an example of a track call which will fail because the invalid email:

{
  "type": "track",
  "event": "Send Gift Card",
  "properties": {
    "name": "Shigeru Miyamoto",
    "email": "nintendo.com"
  }
}
{
  errors: [{
    "title": 'Invalid Attribute',
    "detail": "Email is invalid",
    "status": "400"
  }]
}

And here's an example where attributes are missing:

{
  "type": "track",
  "event": "Send Gift Card",
  "properties": {
    "name": "Shigeru Miyamoto"
  }
}
{
  errors: [{
    "title": 'Invalid Attribute',
    "detail": "No 'email' property is specified",
    "status": "400"
  }]
}