Match Geo-Location to Closest Office

#1

I’m hoping to use geo-targeting to match a viewers location with the closest office. We have a list of offices and addresses, I just can’t think about the right tool to use to automatically display the closest one to the page viewer. Any ideas?

#2

Hi @Lightfuss,

The answer to your question really depends on how accurate you want to be and whether you are collecting the visitor’s location yourself or you would depend on an API to do it.

If you are not collecting the visitor’s location, you can use a 3rd party API to try an estimate the location.

Usually, these 3rd parties work well on State level and somewhat accurate on the City level. There is a variety of reasons, mostly technical, why that’s the case.
(Of course, this assumes we are talking about the US)

Now, depending on your particular use case and how many offices you have in a particular area, it might get tricky to be 100% accurate.

Keeping all of the above in mind, my agency has used IPinfo as a 3rd party to get the visitor’s locations for various custom scripts.

You can start with it and depending on your particular set up go from there. With the help of some JS, you should be able to display the closest location.

Best,
Hristian

#3

Thanks for the thoughtful reply. That makes sense and I think obtaining the location to an acceptable level will be easier with third-party data. I guess where I really get lost is the actual implementation of the JS and the trigger on the page to load the script.

#4

There is no need to have a trigger if you are doing it through JS. As soon as the script is loaded it will execute.

As I’ve mentioned in my original post, the actual implementation would be highly specific to your page. The script will need to be coded for your page(s) so you won’t find something that would work out of the box.