You can reverse the IP address to gather geographical imformation using an external API. Services such as http://www.geoiptool.com provide excellent information. You can then populate custom fields. The Inferred City and similar are not exposed to SOAP API.
Please keep in mind GeoIP is relatively accurate. Users connecting through a corporate VPN may have discrepant informatiion between the country they fill in a form and the inferred country. That is expected since most VPN will have the VPN based on corporate node rather than its actual location.
We use Maxmind to do what you are wanting, their API is pretty easy to work with.
We collect all of this data using their webservice API:Geo-IP LatitudeGeo-IP LongitudeGeo-IP CityGeo-IP StateGeo-IP Postal CodeGeo-IP CountryGeo-IP TimeZoneGeo-IP ConnectionTypeGeo-IP ISP
As bgomes said, there are some quirks with GeoIP- we've noticed if someone is browsing on a cell phone it may show a different state then where the user is. You can write your script to ignore the geoIP data when the ISP has 'cellular', 'wireless' etc. in the name.
hope it helps!
Thank you both. It's a bit of a bummer to reinvent the wheel here. We'll probably use Maxmind too, but that won't populate the Inferred fields that I already have smart lists built against. I think it would be great if from the SOAP API I could pass in the requester's IP and Marketo did the geo call and populated all of the standard Inferred fields.
Reviewing some of my older posts and thought I'd mention the approach we landed on here. We've moved on to the REST API and use associateLead to tie the user's munchkin cookie to the lead we're interested in. In most cases this seems to preserve their anonymous IP and inferred fields. I can't remember for sure if we ever got this to work with the SOAP API and syncLead.