Skip to main content

Introduction

The truemetrics SDK supports logging of not only sensor data but also metadata from your mobile application. This allows you to enrich truemetrics data with specific courier events and data to get most of truemetrics data.

When to send metadata and what to use as trigger

When is the right time to send metadata? The truemetrics algorithm matches the metadata closest in time to the stop event. Most customers choose an interaction that occurs close to the actual service, such as scanning the parcel or the courier swiping to confirm arrival at the delivery location. Try to avoid triggers that the driver might often forget, such as marking the delivery as closed or starting navigation to the next stop, as this can lead to mismatches between the metadata and the stop data in truemetrics. If you’re unsure, either discuss this with truemetrics or use multiple triggers to send metadata. Just make sure to include the type of trigger so that the data is not interpreted as multiple deliveries.
Example KeyExample Value
type_triggerjob_finalized / scan_performed

How to send metadata

Basic metadata logging:
val sdk = TruemetricsSdk.getInstance()
sdk.logMetadata(mapOf(
    "userId" to "user123",
    "orderId" to "order_456"
))
For more detailed explanation go to logging metadata docu

Required Metadata Fields

Normalized Addresses

For validation, the normalized address of the delivery is required to be logged into the truemetrics data. It is best practice to send an object similar to the following example:
Example KeyExample Value
country_codeDE
postal_code10762
streetPflanzstrasse
house_number5

Identifiers

Most customers already have internal identifiers for deliveries, parcels, tours, and other related entities. truemetrics automatically enriches stop KPIs, parking spots, and entrances by using these identifiers. This makes it easier you to track, check, and evaluate truemetrics data.
Example KeyExample Value
identifier_driver1kl234abc
identifier_tour4d1234abc
identifier_delivery0a1234abc
identifier_stop531234abc

Reference Location

The truemetrics algorithm does not rely on the location to which you are sending your driver. Nevertheless, in the early stages of integration, many customers find it useful to compare the actual delivery location with the expected location to assess the accuracy of the address and geocoder.
Example KeyExample Value
lat40.3123
lon13.533

Additional Best Practices

Service Type

Stop times can vary significantly depending on the type of service performed. Was it a fast B2B drop-off with a single parcel, or a more complex B2C pickup requiring a signature? You know best what is important for your business, and truemetrics allows you to enrich the data with your specific categories, enabling you to later analyze the data based on those categories. Typical examples:
Example KeyExample Value
type_consigneeB2C
type_stoppickup (or drop-off)
type_serviceE42c (internal code)

Vehicle types

Some of our customers have multiple vehicle types e.g. Trucks, cars and two-wheelers. Especially for parking places, it’s quite interesting to be able to seperate this data by the type of the vehicle. To do that, just introduce a new key-value pair and log the vehicle type.
Example KeyExample Value
type_vehiclecar

Advanced Metadata Features

Metadata Templates

Create reusable templates for consistent metadata structures:
val sdk = TruemetricsSdk.getInstance()

// Create a template
sdk.createMetadataTemplate("delivery", mapOf(
    "type" to "delivery",
    "version" to "1.0"
))

// Retrieve a template
val template = sdk.getMetadataTemplate("delivery")

// List all templates
val templateNames = sdk.getMetadataTemplateNames()

// Remove a template
sdk.removeMetadataTemplate("old_template")

Tagged Metadata

Build metadata incrementally using tags:
val sdk = TruemetricsSdk.getInstance()

// Create tagged metadata from a template
sdk.createMetadataFromTemplate("current_delivery", "delivery")

// Add data incrementally
sdk.appendToMetadataTag("current_delivery", "orderId", "123")
sdk.appendToMetadataTag("current_delivery", mapOf(
    "lat" to "52.5",
    "lon" to "13.4"
))

// Log when ready
sdk.logMetadataByTag("current_delivery")

// Clean up
sdk.removeMetadataTag("current_delivery")

Tagged Metadata API Reference

MethodReturn TypeDescription
createMetadataTemplate(name, data)UnitCreate reusable template
getMetadataTemplate(name)Map<String, String>?Get template by name
getMetadataTemplateNames()Set<String>List all templates
removeMetadataTemplate(name)BooleanRemove template
createMetadataFromTemplate(tag, template)BooleanCreate tag from template
appendToMetadataTag(tag, data)UnitAppend map to tagged metadata
appendToMetadataTag(tag, key, value)UnitAppend single key-value to tag
getMetadataByTag(tag)Map<String, String>?Get tagged metadata
getMetadataTags()Set<String>Get all active tags
logMetadataByTag(tag)BooleanLog tagged metadata
removeMetadataTag(tag)BooleanRemove tag
removeFromMetadataTag(tag, key)BooleanRemove key from tag
clearAllMetadata()UnitClear all templates and tags