To enable Segment.io integrations, go to the Integrations section, then find Segment.io, and click on Setup.
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.
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.
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.
The Product Fruits username
field should match the userId
field of Segment.io (it is the value you pass to analytics.identify(xxx)
). If this is not true, you will most likely get duplicated users in Product Fruits.
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.
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"
}