GPS tracking and telematics
Fleets rely on real-time GPS and telematics data to monitor vehicle locations, plan dispatches, and maintain visibility into delivery progress.
Why GPS Tracking Matters for TMS
-
Real-Time Dispatch Decisions
- Assign the closest driver or asset to a new load based on their GPS location.
- Quickly react to route deviations, traffic delays, or unexpected stops.
-
Accurate ETAs
- Improve customer satisfaction by providing live delivery ETAs.
- Automatically adjust schedules when drivers are off schedule.
Integration Approaches
Samsara provides multiple ways to retrieve GPS and telematics data for a TMS. Each approach has trade-offs.
- 1. API Polling: Make API requests on a periodic basis to fetch the latest data. For simpler integration and less time-sensitive use cases.
- 2. Webhooks: Receive notifications when events happen in Samsara (excluding updated positions). Best for specific events (arrivals, departures, geofence-based logic).
- 3. Event Streaming: Receive near real-time data via Kafka. Requires more customer setup.
Often, a hybrid approach works best. For example, you might use webhooks for arrivals/departures and polling the snapshot or feed API endpoints to keep an updated map of vehicle locations in your TMS.
1. API Polling
- Description: Your TMS periodically calls the Samsara API to pull the latest GPS updates for vehicles.
- Use Case: Suitable for lower-frequency updates (e.g., every 1–5 minutes).
- Endpoints:
GET /fleet/vehicles/stats
(snapshot)GET /fleet/vehicles/stats/feed
(feed)GET /fleet/vehicles/stats/history
(historical)
/fleet/vehicles/stats/feed
- Recommended for real-time or close-to-real-time TMS tracking.
- Returns telematics “events,” such as GPS, engine states, odometer, etc., since your last request.
- Poll interval depends on how frequently you need updates (often 5–15 seconds).
/fleet/vehicles/stats/history
- Fetch historical data for a given time range.
- Use for backfilling data or generating daily reports (not recommended for continuous syncing).
/fleet/vehicles/stats
- Retrieve the latest snapshot of each vehicle’s location and telematics data.
- Can be used for occasional or on-demand location updates.
2. Webhooks
Consider these events for automated dispatch workflows (e.g., send an alert if a vehicle arrives late).
- Description: Samsara sends webhook events like
GeofenceEntry
,GeofenceExit
,RouteStopArrival
, andRouteStopDeparture
. - Use Case: Event-driven workflows (e.g., “Notify dispatch when a truck enters the depot geofence”). Not intended for continuous GPS streaming.
GeofenceEntry
and GeofenceExit
GeofenceEntry
and GeofenceExit
Triggers when a vehicle crosses a geofence boundary.
RouteStopArrival
and RouteStopDeparture
RouteStopArrival
and RouteStopDeparture
Triggers when a route stop is reached or departed.
3. Event Streams with Kafka
- Description: Samsara’s Kafka Connector pushes high-frequency GPS updates (and other telematics data) to your Kafka topic in real time.
- Use Case: Enterprise-scale TMS solutions requiring low-latency streaming and the ability to handle continuous, high-volume data (e.g., large fleets, advanced analytics).
GPS and Speed
and Vehicle Diagnostics
GPS and Speed
and Vehicle Diagnostics
{
"happenedAtTime": "2025-02-01T17:57:21Z",
"asset": {
"externalIds": {},
"id": "154924973293665"
},
"location": {
"latitude": 38.253265915,
"longitude": -80.018465004,
"headingDegrees": 102
},
"speed": {
"gpsSpeedMetersPerSecond": 43.8,
"ecuSpeedMetersPerSecond": 51.2
}
}
Requires each customer to set up the Samsara Kafka Connector and for you to implement a Kafka consumer in your TMS environment.
Sample Flow: Real-Time Vehicle Tracking
Below is an example of how you might build near real-time tracking:
-
Initialize
- Call
GET /fleet/vehicles/stats?types=gps
once to get a snapshot of current vehicle locations.
- Call
-
Continuous Sync
- Poll
GET /fleet/vehicles/stats/feed?types=gps
every 5 seconds to grab any new GPS events. - Store each event in your TMS database using
vehicle.externalIds.tmsId
.
- Poll
-
UI Updates
- Your TMS front-end can display updated vehicle markers on a map as soon as new GPS events are saved.
-
Webhooks for Route Stops (optional)
- When a driver arrives at a stop (
RouteStopArrival
), automatically update the order status in your TMS.
- When a driver arrives at a stop (
-
Analytics & Archiving
- Periodically offload or archive older data for historical tracking and reporting.
Updated 19 days ago