Calculate the distance between two latitude/longitude points.

float distance(float latitude_1, float longitude_1, float latitude_2, float longitude_2[, string units])
  • latitude_1 and longitude_1 represent a coordinate pair
  • Coordinates must be floats, and can be inserted as saved variables. Passing a string results in an error.
  • Units is optional, and can be either "mi" (miles) or "km" (kilometers). The default value is miles. Quotation marks are required.

Using this function, you can tailor content based on user location.


Distance in Miles


Distance in Kilometers


Distance Between Location and Profile Var Coordinates


Note: If you have latitude and longitude saved as strings on the user’s profile, you will first need to convert them to numbers.

Conditional Message Using Distance

In the following example, the message “Point B is within 10 miles of Point A!” only appears if the Point B is less than 10 miles from Point A.

{if {distance(40.7267926,-74.0053737,40.500819,-74.447399) < 10}
Point B is within 10 miles of Point A!