Integration using Segment

This section serves as a guideline for developers on the Publisher backend, facilitating the integration of Zendrive webhook with Segment.

Prerequisites:

  • Publishers have accounts in Segment.io to obtain access to the required API keys.

  • The webhook provided by Zendrive backend service has a driver_id. This unique identifier is used to send data to Segment.

Procedure:

  1. Log in to Segment.io.

  2. To send data to Segment, add a Source. For example, to send data from Python Server to Segment: Go to CatalogSourcesSearch for PythonAdd Source. a. To set up Segment using Python, refer to Quickstart: Python | Segment Documentation. Below is the code snippet that must be added to the server:

import segment.analytics as analytics


analytics.write_key = 'YOUR_WRITE_KEY'


analytics.identify(‘test_driver’, {
'email': ‘test_driver@gmail.com’,
'name': ‘Test user’
})


analytics.track(‘test_driver’, ‘Webhook fired’, {
'type': ‘Webhook fired’,
'subtype': ‘First trip’,
'trips_count': 1
})

b. The function records two events with the required payload: Identify and Track. c. The events are recorded in the Segment as follows:

  1. To forward data to MarTech tools like Iterable, Braze, and others, use the Destination feature.

    For example, To send data to Iterable from Segment: Go to CatalogDestinationsSearch for IterableAdd Destination.

To configure Iterable as a destination, follow the steps prescribed in Iterable as destination.