As I’ve setup my Podio systems and processes I’ve come about situations where I need to have a full address string (123 Main St, Somecity, NJ 07981) and other times where I’ve needed only parts of the address…like just the city or the County that the property is in.
So the question is, should I have my address field as a single line Location field in Podio or have multiple fields for each part of an address? I know the Location field does have a Multi-Line option, but I’ll get into the issues with that later.
Multiple Fields vs Single Line
I advocate for always going with a multiple field approach. The reason being is that you can always build an address from the different address parts, but you can’t always break an address into it’s parts.
…you can always build an address from the different address parts, but you can’t always break an address into it’s parts.
Let me demonstrate what I’m talking about real quick. If you have the address separated out into different fields like so…
Street: 123 South Hampton St
City: Whippany
State: New Jersey
Zip: 07981
You would easily be able to concatenate them in a calculation field by using this formula…
@street + ", " + @city + ", " + @state + " " + @zip
The result would be…
123 South Hampton St, Whippany, New Jersey 07981
Now lets take a look at the reverse. Say you only store the address in a single field. There is no easy way to determine the address parts. You could almost do it by breaking the address up by commas (,). You’ll then be left with breaking up the zip code and the state.
The above address as I typed it could be broken up successfully. It would just take about 10 lines of code.
BUT…and this is a certainty…the address will not always be formatted this way. Here are some of the variations that you might get…
- 123 South Hampton St Whippany New Jersey 07981
- 123 South Hampton Street, Whippany NJ
- 123 South Hampton St, Whippany, NJ 07981-0702
- 123 S Hampton St Whippany, NJ 07981
Everyone seems to have their own style of typing in the address. Taking all these styles into consideration makes any attempt to break up the address parts very difficult and not worth it.
The Podio Location Field does give you the option to use a Multi-Lines style. This does break up the Address into different parts. The issue is that if you try and reference the location field in a calculation, in globiflow or other third party services, you can’t reference the different parts (like city). You only get the full address. Maybe they will change this in the future but that’s not how it is now.
Additional Address Info
In addition to the address of the property, I like to have the county they live in plus the neighborhood. Sure I can just ask them these questions on my contact form. But the more questions you have on your contact forms (or that you need to ask the sellers) the less likely they are to follow through and give you the information you want.
It is also annoying to have inconsistent data across all your leads. Wouldn’t you like to have all of the following for every lead you enter into your lead App in Podio?
- Street Number
- Street Name
- Neighborhood
- City
- County
- State
- Zip
- Zip Suffix
- Country
- Longitude
- Latitude
- Properly Formatted Address
I sure has heck would! Here is how you can do that…
Quick Demonstration
Before I get into the details behind how this is done, I wanted to show you what it looks like real quick.
Using Google to get Address Info
Google has a web service where you can request and get all the address information that I listed above. It’s free to use which is hard to imagine. The concept is very simple and just getting the information is just as simple.
To get the full address information for a property you just have to browse (using a standard web browser) to the following url and add onto it the address like so…
https://maps.googleapis.com/maps/api/geocode/json?address=[your property Address]
Here is an example you can click on see the result..
https://maps.googleapis.com/maps/api/geocode/json?address=205 york st burlington nj
The great part about the Google API is that you don’t need the entire address to have it work. You don’t even need to have it formatted in any particular way. You’ll notice that I left off the zip code.
What you’ll get back is all the address information. It will be in a specific format called JSON. What that is is just a web standard for transferring data in an easy to handle format.
{
"results" : [
{
"address_components" : [
{
"long_name" : "205",
"short_name" : "205",
"types" : [ "street_number" ]
},
{
"long_name" : "York Street",
"short_name" : "York St",
"types" : [ "route" ]
},
{
"long_name" : "Burlington",
"short_name" : "Burlington",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Burlington County",
"short_name" : "Burlington County",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "New Jersey",
"short_name" : "NJ",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "08016",
"short_name" : "08016",
"types" : [ "postal_code" ]
},
{
"long_name" : "1502",
"short_name" : "1502",
"types" : [ "postal_code_suffix" ]
}
],
"formatted_address" : "205 York St, Burlington, NJ 08016, USA",
"geometry" : {
"location" : {
"lat" : 40.081046,
"lng" : -74.85589
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : 40.0823949802915,
"lng" : -74.85454101970851
},
"southwest" : {
"lat" : 40.0796970197085,
"lng" : -74.85723898029151
}
}
},
"place_id" : "ChIJkdLuj2FOwYkRwgo-g_J8hNA",
"types" : [ "street_address" ]
}
],
"status" : "OK"
That is some pretty awesome stuff right!?!
Getting This Into Podio
So how do we automate this and get the address parts into separate fields in Podio? Great question! The answer is a 2 step process that requires us to use GlobiFlow for part one. Then in part two we will create calculation fields to break out the different address parts. This second part was the more difficult part to figure out.
Step #1: Location Field in Podio
The first part of the process is to make sure you have a Location Field in Podio that you store your lead’s address in.
Step #2: Text Field in Podio
This text field is going to be the place where you store the Full Address Information you get back from Google in that JSON format. So add a text field into your Podio App that has the Multi-Lines option selected.
Step #3: GlobiFlow Process
In GlobiFlow we will need to setup a Flow that is triggered off the creation of the property record. This is a fairly simple flow even though it uses an Action that most people are probably confused about.
The Remote Post/Get Action is used to call out to a web address (web service or api). That web address will return back some information that GlobiFlow will store in a variable.
If you were to add this action to your flow it would look like this…
To get this Action working and making a call to the Google Maps API fill in the fields with the values you see below.
Variable Name: AddressJSON
Selection: GET
From Url: https://maps.googleapis.com/maps/api/geocode/json
Get Params: address=[(Property) Address]
Post Params:
Additional Information
You will need to use the field selector on the “Get Params” line to select the Address Field for your podio setup. The example above, [(Property) Address], is from my setup. GlobiFlow doesn’t allow you to type in the field (token) you have to select it from the Field (token) selection list.Now that you have the Address information from Google Maps stored in the AddressJson variable, we need to save that to your Podio Lead Item. To do this we will use an Update Item Action.
When you drag that over to your Flow it will look something like this…
Next you will select the field you want to put the Google Map JSON information into. In my podio setup I called it AddressJSON.
Lastly you select the Variable name that you used in the Remote Post/Get from the Field (token) selection list.
Below is how mine looks when all is set.
Now you just give the Flow a name and save it.
What you have done so far…
We are not finished yet, but I wanted to review what we have before moving on to the last step.
If you were to add a new lead to Podio right now, globiflow would make a call to the Google MAPS API and return to you the full Address Information in JSON format (see image above). This information will be stored in the AddressJSON field in your Podio Lead App.
That’s pretty cool right? At least I think so. The problem with this is that information, formatted like that, is not very useful to us. We need to pull out the individual address parts and put them in their own fields. In the next section I will show you how to do that.
Get Address Parts from JSON
To be honest this part is not for the timid. It requires some ugly looking calculation field code. Most of you probably didn’t realize that you could do this in a calculation field but lucky for us you can.
Calculation fields run on a language called javascript. Which is great because we can use javascript to read and parse out the information we need from the JSON structured text we got from Google Maps.
Add Address Fields to Podio
Back in your Podio Leads App we now need to add 12 new calculation fields. These fields will be for each of the address parts that we want to pull out of the JSON.
- Full Address
- Street Number
- Street
- Neighborhood
- City (locality)
- County
- State
- Country
- Zip Code
- Zip Code Suffix
- Latitude
- Longitude
The JSON is structure for storing data in a uniform way. The best way to explain it is to show you a simplified version of it…
TO simply put it, we have to just navigate our way through the hierarchy to get the information we want.
The killer thing though is that Google doesn’t always return all the information. Sometimes their is no Neighborhood and only city.
So my script will loop through each item and check the “TYPE” value. If it matches what I’m looking for I will grab the address part for the field.
This approach actually makes things simpler in the fact that I can reuse the same code (only changing what I’m looking for) for each Podio Address field.
Code for Main Address Parts
There are 3 different code blocks that will be used to get all the information. This first code block will be used to get the Street Number, Street, Neighborhood, City, County, State, Postal Code, Postal Code Suffix and Country.
try {;
var results = JSON.parse(@Address JSON).results;
var ac = results[0]address_components
for (var i = 0; i > ac.length; i++) {
if(ac[i].types[0] == "<put type here>") {
ac[i].short_name;
break;
}; else {
"-";
}
}
} catch (e) {
"-"
}
After you cut and paste this code into your Podio Calculation fields you’ll have to do 2 things…
1 – Re-Enter the @AddressJSON field token. Anytime you cut and paste into a podio calculation field you have to re-enter any field references. So just erase @AddressJSON and type in the @ symbol followed by what you called the AddressJSON field. As you are typing you should see the field in the pick list the appears. Select it from there.
2 – Replace the Text <enter type here> with the Address Part type you are looking for. Take a look at the image to the right to see where the Type information can be found.
Code Block for Longitude and Latitude
This code block will be used to get the longitude and latitude information from the Geometry branch of the JSON file. It’s a different route, but is much simpler to get then the Address Components. No looping involved, we can just navigate our way directly to the information.
try {
var results = JSON.parse(@Address JSON).results;
var ac = results[0].geometry.location['<enter type here>'];
String(ac)
} catch (e) {
"Could not parse JSON"
}
Just like in the previous block, you have to do 2 things once you cut and paste this into your Podio Calculation Field.
1 – Re-Enter the @AddressJSON field token. Anytime you cut and paste into a podio calculation field you have to re-enter any field references. So just erase @AddressJSON and type in the @ symbol followed by what you called the AddressJSON field. As you are typing you should see the field in the pick list the appears. Select it from there.
2 – Replace the Text <enter type here> with the Address Part type you are looking for. In this case it’s either lng for Longitude or lat for Latitude.
Code Block for Formatted Address
Google Maps returns a Formatted Address string in the JSON as well so I like to pull that into a field. Its easy enough and comes in handy from time to time. This code is just like the Latitude and Longitude code.
try {
var results = JSON.parse(@Address JSON).results;
var ac = results[0].formatted_address;
String(ac)
} catch (e) {
"-"
}
After cutting and pasting this code you only have to do 1 thing.
1 – Re-Enter the @AddressJSON field token. Anytime you cut and paste into a podio calculation field you have to re-enter any field references. So just erase @AddressJSON and type in the @ symbol followed by what you called the AddressJSON field. As you are typing you should see the field in the pick list the appears. Select it from there.
That’s It!
Now every time you add a new lead to your Podio Leads App you’ll get actual Google MAPS data right into Podio. Like I have said earlier in the post, I use this to make sure I have all the parts of an address including the County that the lead belongs too.
If you would like a full video tutorial on how I set this process up in my system click the button below.
Share this Post
Free Video Tutorial!
Bring Me to the VideoThe post Podio Quick Tip – Getting Address Info from Google Maps appeared first on Struggling Investor.