Skip to content

Track Endpoint

Capturing how your users interact with your platform is crucial for understanding their behavior and optimizing your sales. Our Track endpoint allows you to record key actions (events) that users perform on your website, such as purchase attempts or failed payments.

Based on our experience in the transportation industry, we have defined a relevant data schema for your business.

We process and store this information so you can easily visualize it in your Mixpanel dashboard or analyze it in detail using SQL queries, thus obtaining valuable insights for your business.

Events

Events are the way you can capture your users’ data. Currently, our Track endpoint supports the following events:

NameDescriptionPurpose
Payment FailedWhen the user attempts to complete the purchase but the payment fails.It will allow you to understand the types of problems your users are facing when trying to complete the purchase.
Purchase CompleteWhen the user successfully completes the payment and their tickets are generated.The most important information for your business, it’s a fundamental basis for comparing and understanding how to improve your sales.

Trip Schema

All events share a base schema for trip-related data. This schema corresponds to the trip field, which is an object with the following properties:

FieldTypeRequiredDescription
departure_arrivalstring (date-time)Arrival date and time of the outbound trip in ISO 8601 format
departure_destinationstringDestination city of the outbound trip
departure_destination_terminalstringDestination terminal of the outbound trip
departure_linestringBus line for the outbound trip
departure_originstringOrigin city of the outbound trip
departure_origin_terminalstringOrigin terminal of the outbound trip
departure_pricenumberPrice of the outbound trip
departure_routestringRoute of the outbound trip
departure_stop_citiesstringStop cities on the outbound trip, separated by commas
departure_stopsintegerNumber of stops on the outbound trip
departure_timestring (date-time)Departure date and time of the outbound trip in ISO 8601 format
departure_transporterstringTransporter company for the outbound trip
discount_codestringDiscount code applied to the trip
recommended_tripbooleanIndicates if it’s a recommended trip (valid only for recommendation service clients)
recommended_trip_typestringType of trip recommendation (valid only for recommendation service clients)
return_arrivalstring (date-time)Arrival date and time of the return trip in ISO 8601 format
return_destinationstringDestination city of the return trip
return_destination_terminalstringDestination terminal of the return trip
return_linestringBus line for the return trip
return_originstringOrigin city of the return trip
return_origin_terminalstringOrigin terminal of the return trip
return_pricenumberPrice of the return trip
return_routestringRoute of the return trip
return_stop_citiesstringStop cities on the return trip, separated by commas
return_stopsintegerNumber of stops on the return trip
return_timestring (date-time)Departure date and time of the return trip in ISO 8601 format
return_transporterstringTransporter company for the return trip

Event Schemas and Parameters

For each event, the object structure is as follows:

{
"event_name": "payment_failed" | "purchase_complete",
"event_data": {
...
"product": "web" | "web-mobile" | "ios" | "android" | "ticket-office" | "travel-agency" | "call-center",
"trips": [
{
...
},
]
...
}
}

Additional fields specific to each event are added at the event_data level. The trips array contains a list of trip objects following the Trip schema fields.

Payment Failed

When a user attempts to complete the purchase but the payment fails, you’ll want to know the reasons why and the details of the chosen trip to help them complete the purchase.

FieldTypeRequiredDescription
agency_namestringName of the travel agency involved in the booking
couponstringPromotional coupon applied
discount_codestringDiscount code applied
distinct_idstringUnique identifier for the user’s purchase attempt session
emailstringUser’s email address in valid format
error_messagestringError message provided by the payment engine
installmentsintegerNumber of installments selected for payment
insurancebooleanIndicates if any type of insurance offered by your business was included
ipstringUser’s IP address (used for geolocation)
latitudenumberLatitude of the user’s location
longitudenumberLongitude of the user’s location
metaobjectObject where you can add any additional information you deem relevant
operation_idstringUnique identifier for the booking operation
passenger_countintegerTotal number of passengers
payment_card_affiliatestringPayment card affiliation
payment_enginestringPayment engine used
payment_typestringSelected payment type
phonestringPhone number in E.164 format (e.g., +12125551234)
productstringIdentifier of the product or sales channel
ticketsintegerTotal number of tickets
totalnumberTotal amount of the booking
tripsarrayArray of trip objects
trips_countintegerNumber of trips in the booking
user_fingerprintstringUnique identifier of the user’s device
user_statusstringUser status

Purchase Complete

When a user successfully completes the purchase, you’ll want to know the booking details to offer better experiences to your customers.

FieldTypeRequiredDescription
agency_namestringName of the travel agency involved in the booking
couponstringPromotional coupon applied
distinct_idstringUnique identifier for the user’s purchase attempt session
emailstringUser’s email address in valid format
insurancebooleanIndicates if any type of insurance was included in the booking
ipstringUser’s IP address (used for geolocation)
latitudenumberLatitude of the user’s location
longitudenumberLongitude of the user’s location
metaobjectObject with additional event information
operation_idstringUnique identifier for the booking operation
passenger_countintegerTotal number of passengers
payment_card_affiliatestringPayment card affiliation
payment_typestringSelected payment type
phonestringPhone number in E.164 format (e.g., +12125551234)
productstringIdentifier of the product or sales channel
ticketsintegerTotal number of tickets
totalnumberTotal amount of the booking
tripsarrayArray of trip objects
trips_countintegerNumber of trips in the booking
user_fingerprintstringUnique identifier of the user’s device
user_statusstringUser status
FieldTypeRequiredDescription
bus_categoriesstringCategories of the purchased tickets, comma-separated
departure_transport_typestringTransport type for the outbound trip
return_transport_typestringTransport type for the return trip

Notes

Schema constraints are key to ensuring data integrity so you can gain the most relevant insights for your business.

If you are having trouble sending data, carefully review the error handling section.

Examples

Below are examples of how to send a Purchase Complete event to the Track endpoint using different programming languages.

Terminal window
curl \
-X POST '<BASE_URL>/datalake/track' \
-H 'Authorization: <Bearer_Token>' \
-H 'Origin: https://your-domain.com' \
-H 'Content-Type: application/json' \
-d '{
"event_name": "purchase_complete",
"event_data": {
"passenger_count": 2,
"payment_type": "credit_card",
"trips_count": 1,
"tickets": 2,
"total": 31.00,
"product": "web",
"email": "john.doe@example.com",
"phone": "+12154567890",
"trips": [{
"departure_arrival": "2025-04-25T10:30:00-05:00",
"departure_destination": "Boston",
"departure_destination_terminal": "South Station",
"departure_line": "Coastal Express",
"departure_origin": "New York",
"departure_origin_terminal": "Port Authority",
"departure_price": 15.50,
"departure_route": "NY-BOS",
"departure_stop_cities": "New Haven",
"departure_stops": 1,
"departure_time": "2025-04-25T15:30:00-05:00",
"departure_transporter": "East Coast Bus Company",
"bus_categories": "general",
"departure_transport_type": "bus"
}]
}
}'

In this example:

  • A simple trip from New York to Boston is shown.
  • Required fields for the Purchase Complete event are included.
  • Additional required fields for each trip object (bus_categories and departure_transport_type) are added.

Responses

Successful Response

{
"message": "Event success stored",
"status": "success"
}

The successful response indicates that the event has been stored correctly and is being processed.

Error Response

In case of an error, you will find a list of reasons why the event could not be processed, as well as suggestions for correcting the problem. Refer to the errors section for more information on how to resolve the errors you encounter.