Technical8 min read

How to calculate shipping per kilometer in a quote with Google Maps

If you charge freight or installation by distance, eyeballing it costs you money or sales. How to calculate shipping per kilometer with Google Maps inside a quote, with the EQUIBOX case.

Facundo Campo··Updated
How to calculate shipping per kilometer in a quote with Google Maps

To calculate shipping per kilometer in a quote, the system takes the customer's address, asks Google Maps for the road distance from your factory and applies your rate. The result goes straight into the quote, without the sales rep opening a map and doing the math.

Here is how it works, which rules you need to define yourself and how I built it into the sales system of EQUIBOX, a horse stable manufacturer in Argentina where shipping and installation depend on distance.

Why is eyeballing it not good enough?

Because shipping is usually a big part of the price when you make something large, and the error always goes one way or the other: underestimate it and you lose money on every trip; overestimate it to be safe and you lose sales to someone who quoted more precisely.

Also, when each sales rep calculates it their own way (one with the map, another with “it's about 200 km”), two customers in the same area get different numbers. With automatic calculation, the same address always gets the same shipping cost.

Straight-line or road distance?

Road distance. Straight-line distance is calculated with a formula and needs no external service, but it is not what the truck drives. In rural areas, where you have to go around fields and rivers or drive to the nearest highway access, the difference can be large.

For this, Google offers the Distance Matrix service, part of Google Maps Platform: you give it an origin and a destination and it returns the road distance and travel time. It is the one I used at EQUIBOX.

How does the calculation work, step by step?

  • The sales rep enters the customer's address or town. Ideally with autocomplete, so there are no typos.
  • The system looks up the road distance between the factory and that destination.
  • It applies your rate: the price per kilometer and whatever rules you defined.
  • It adds the result to the quote, on its own line, so the customer sees how much is product and how much is shipping.
  • It is saved with the quote, so the quote does not change if the rate is updated later.

Which rules do you need to define?

Google gives you the distance; how it turns into money is a business decision. These are the typical questions:

  • Do you charge one way or round trip? The truck drives back empty anyway.
  • Is there a minimum? Shipping 5 km does not cost five times less than shipping 25 km.
  • Does the rate change by distance band? For example, one rate up to a certain distance and another beyond it.
  • Are shipping and installation calculated the same way? Installation can have its own distance-based cost on top of freight.
  • Do you round? A round number reads better in a quote.
  • How far do you go? If there are areas you do not ship to, the system should flag it.
Real case

How did I build it into EQUIBOX?

EQUIBOX manufactures modular horse stalls and stables in Berazategui, near Buenos Aires, and in its quotes shipping and installation depend on distance. Before, that calculation was part of the quote built by hand.

In the sales panel I built for them, the sales rep quotes with prices and shipping is calculated per kilometer with Google Maps (Distance Matrix), along with installation, payment plans and coupons. Everything goes into the PDF quote and the WhatsApp message.

Only the team sees that part, behind their login: the public 3D configurator shows no prices or shipping. The buyer designs their stable, downloads the spec sheet and requests a quote over WhatsApp, and the sales rep replies with everything calculated.

See the EQUIBOX case study

What are the options for charging shipping?

Zone tableMap + calculatorAutomatic per-km calculation
How it worksA fixed price per zone or town.The sales rep measures on the map and does the math.The system looks up the distance and applies the rate.
AccuracyLow in large zones.Good, if nobody makes a mistake.Good and always consistent.
Sales rep timeLittle.Several minutes per quote.None.
MaintenanceUpdating the table.None, but it depends on each person.Updating the rate in one place.
Best forShort trips and small zones.A few quotes.Long distances or nationwide shipping.

What technical precautions are needed?

If you are the one ordering the system, these are the points your developer should keep in mind. If you are a developer, these are the ones I check:

The Google key is money. Google Maps Platform charges by usage, so the key has to be restricted so only your system can use it. Even better if the lookup runs on the server and the key is not exposed in the browser.

Save the result. The distance and the shipping amount are saved with the quote. That way the quote the customer received does not change if the rate changes tomorrow, and Google is not queried again every time it is opened.

Plan for no signal. If the system is also used in places with no internet, as happens at EQUIBOX with rural expos, the Google lookup cannot happen on the spot. That case has to be solved by design: I cover it in an app to sell at expos without internet.

How much does it cost to add?

Shipping calculation almost never comes alone: it is one piece of a quoting or sales system. The cost depends on the scope of that system: how many products and options it quotes, which rules shipping and installation follow, and what it connects to (PDF, WhatsApp, your customer list). Tell me how you quote today and I will send you a fixed quote within 48 hours. I explain how shipping fits with the rest of the system in sales system and CRM for manufacturers, and how it shows up in the document the customer receives in automatic PDF quotes.

Frequently asked questions

How is shipping per kilometer calculated?

You take the road distance between the factory and the customer's address and apply whatever rate you define: a price per kilometer, plus any rules you add (minimum, round trip, rounding). If the system asks Google Maps for the distance, the calculation happens automatically when the address is entered.

Why not use straight-line distance?

Because the truck does not travel in a straight line. The road distance can be much longer, especially in rural areas, and it is what actually costs you.

What is Google Distance Matrix?

It is a Google Maps Platform service that returns the road distance and travel time between one or more origins and destinations. It is what the EQUIBOX system uses to calculate shipping.

Does using Google Maps cost money?

Google Maps Platform charges by usage under its current plans. It is worth checking its terms before you start and restricting the key so only your system can use it.

Can the customer see the shipping cost?

That is up to you. At EQUIBOX, the shipping calculated per kilometer is seen by the sales rep in the priced quote; the public version of the configurator shows no amounts.

Your project

If you charge shipping or installation by distance and calculate it by hand today, tell me where you ship from and how you set your rate. I will tell you what it would look like automated.

#calculate shipping cost per km#freight cost per mile calculator#google maps distance for quotes#quote calculator with shipping cost#google distance matrix api