Segment.io integration

We support two integration types. You can send Product Fruits events to Segment.io or you can receive events and user information from Segment.io through webhooks.

Activating Segment.io integrations

To enable Segment.io integrations, go to the Integrations section, then find Segment.io, and click on Setup.

Sending Product Fruits events to Segment.io

We can send different Product Fruits events from Product Fruits to Segment.io. For instance, when a user completes a tour, when a checklist is dismissed, etc. The list of supported events is here.

Please note, that this integration uses Segment.io JavaScript SDK which must be installed in your application and the analytics variable must be available on the JavaScript window object. We call the window.analytics.track() method.

Sending Segment.io events and user information to Product Fruits

This feature is available in the Boost plan.

We support Segment.io integration through their Webhook destination. Before you use this, please check the User tracking modes article.

Open the Segment.io integration box and activate the integration. It will generate a Webhook URL and a Webhook Secret.

Then go to Segment.io, create a new webhook destination and enter the webhook URL and the webhook secret into settings.

Please note, webhook settings in Segment.io can be a little bit confusing. Check the following screenshot, you have to enter the values into the right fields. Don't forget to activate the webhook by clicking on the blue switch.

Users matching - important

What is important is that Product Fruits and Segment.io must share the same user identity. Without this, we would not be able to pair the information received through the webhook to the right user.

We match the particular user like this:

  1. We check email field and try to find the user in Product Fruits by the email user property.
    • If it is found, we will update the information.
  2. If it is not found, we check the if userId field matches the username user property
    • If it is found, we will update the information
  3. If it is not found, we will create a new user

 

Segment.io web JS SDK

If you use Segment.io JS SDK to identify users, you have to call analytics.identify('some_user') somewhere in your code to initialize Segment.io user information. You can also include additional information, for instance, e-mail, first name, last name, etc. 

For example:

// the most basic call, we are sending userId to Segment.io - this must match to the username field in PF
analytics.identify('some_user')

// we can also pass email, then PF will match this to the email field in PF
analytics.identify('some_user', { email: 'someuser@example.com', firstname: 'John' })

The userId in this case is the first parameter of the identify method.

Segment.io REST API

If you are sending data through Segment.IO REST API, provide the userId field in the request payload. 

For example, send a POST request to https://api.segment.io/v1/track with this payload:

{
  "userId": "019mr8mf4r", // this must match to the username field in PF
  "event": "Item Purchased"
}