To enable Segment.io integrations, click on Integrations in the drop down menu in the top right, then locate Segment.io, and click on Setup.
We can send different Product Fruits events from Product Fruits to Segment.io. For instance, events such as 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 both the webhook URL and webhook secret into the settings.
Please note, webhook settings in Segment.io can be a little bit confusing. Check that your values are entered into the correct fields as shown in the following screenshot.. 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 (this 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 the Segment.io JavaScript SDK to identify users, you must 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.
Example:
// The most basic call. We are sending userId to Segment.io - this must match to the username field in Product Fruits
analytics.identify('some_user')
// We can also pass email; then PF will match this to the email field in Product Fruits
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 the Segment.IO REST API, provide the userId
field in the request payload.
For example, you would send a POST request to https://api.segment.io/v1/track
with this payload:
{
"userId": "019mr8mf4r", // this must match to the username field in Prodcut Fruits
"event": "Item Purchased"
}