No-code6 min read
How do you add address autocomplete in Webflow?

Why add an address field with autocomplete?
| Prerequisites | Details |
|---|---|
| Google Cloud Console account | Free to create |
| Places API enabled | In Google Cloud Console > APIs |
| API key | Restrict it to your domain for security |
| Webflow input ID | Add 'address-input' to your field |

Better user experience
- Ease of use: Autocomplete helps users find and enter their addresses faster and more easily.
- Fewer errors: It reduces the risk of mistakes by suggesting valid addresses.
Data accuracy
- Standardization: Entered addresses are often normalized into a standard format, which helps ensure data accuracy.
- Validation: It lets you validate addresses in real time, so the information you receive is accurate.
Efficiency
- Time savings: It cuts down the time users spend filling out forms, which is especially useful on mobile devices where typing can be a pain.
- Less friction: It minimizes the steps needed to complete a form, helping reduce cart abandonment and sign-up drop-off.
All of this helps boost form conversions and make your data more reliable.
Gemeos, the Webflow agency, shows you how to do it!
Tutorial: add a single-field address autocomplete in Webflow

1. Create a Google Cloud Console account and go to Google Maps Platform
Follow this link to get there!
You should see a modal with your API key (see the screenshot below).
Copy your API key so you have it handy, you'll need it for the next steps.

2. Add the "address-input" ID to your input in Webflow

3. Add this custom code to your page or in an embed inside your form
Make sure you add your API key in place of {API key} in the first and second code blocks below.
<script src='https://maps.googleapis.com/maps/api/js?key={API key}&libraries=places&callback=initMap'></script><script>
"use strict";
function initMap() {
const CONFIGURATION = {
"mapOptions": {"center":{"lat":37.4221,"lng":-122.0841},"fullscreenControl":true,"mapTypeControl":false,"streetViewControl":true,"zoom":11,"zoomControl":true,"maxZoom":22,"mapId":""},
"mapsApiKey": "{API key}",
"capabilities": {"addressAutocompleteControl":true,"mapDisplayControl":false,"ctaControl":false}
};
const addressInput = document.getElementById('address-input');
const autocomplete = new google.maps.places.Autocomplete(addressInput, {
fields: ["address_components", "geometry", "name"],
types: ["address"],
});
autocomplete.addListener('place_changed', function () {
const place = autocomplete.getPlace();
if (!place.geometry) {
window.alert('No details available for: \'' + place.name + '\'');
return;
}
fillInAddress(place);
});
function fillInAddress(place) {
const addressNameFormat = {
'street_number': 'short_name',
'route': 'long_name',
'locality': 'long_name',
'administrative_area_level_1': 'short_name',
'country': 'long_name',
'postal_code': 'short_name',
};
let completeAddress = "";
function getAddressComp(type) {
for (const component of place.address_components) {
if (component.types[0] === type) {
return component[addressNameFormat[type]];
}
}
return '';
}
completeAddress += getAddressComp('street_number') + ' ' + getAddressComp('route') + ', ';
completeAddress += getAddressComp('locality') + ', ';
completeAddress += getAddressComp('administrative_area_level_1') + ' ';
completeAddress += getAddressComp('postal_code') + ', ';
completeAddress += getAddressComp('country');
addressInput.value = completeAddress;
}
}
</script>4. Publish and test the result
It doesn't get much simpler than that.



