Calculating distance between two locations using Google Distance Matrix API and Call API feature in Outgrow

Are you looking to fetch data from a third-party tool and use it in your Outgrow content? Now you can with the Call External API feature. You can use this feature to fetch data from a 3rd party tool and use it in your questions, results, PDFs, or user notification emails. You can choose between the Get and Post methods for fetching or pushing the data to the external tool.

If you're interested in learning how to calculate the distance between two locations using a combination of the Distance Matrix API offered by Google and the Call API feature available in Outgrow, keep reading.

Configuring Google Distance Matrix API in Outgrow

To configure the functionality in your Outgrow content, you can follow these simple steps:

1. Login to your Outgrow dashboard and open the respective content in Build mode.

Outgrow Dashboard

2. Go to the respective question in the Build tab and navigate to the Call API sub-tab. Enable the setting for the Add Call API feature.

3. Once the feature is enabled, you can choose the API Request Type as GET.

4. After selecting the appropriate Request Type, you can access API Data using the Public API offered by Google.

Public API

5. You must specify Google's API Endpoint URL in your Outgrow content. For the Distance Matrix API, the requests need to be sent in the following format: https://maps.googleapis.com/maps/api/distancematrix/outputFormat?parameters

NOTE: Here you can learn more about the parameters supported by Distance Matrix API as a part of the API data requests.

πŸ“˜

IMPORTANT NOTE

You can learn more about the parameters supported by Distance Matrix API as a part of the API data requests by visiting the URL provided.

6.Now, under API Details, click on the Edit icon, and in the Body section, specify the parameters you would like to be used to fetch data using Data Matrix API. For example, you can collect answers for questions related to Origin City, Destination City, and Distance Calculation Unit, and send the data as a part of the API Endpoint URL

API Endpoint URL

7. Click on Submit to save the specifications.

8. Click on Test and Reconfigure to configure the API Call.

8. A. One thing to keep in mind is that in the case of Google Distance Matrix API, you need to move the rows.0.elements.0.distance.text variable from All Variables to Selected Variables in order to use the response received from Google as a part of the Questions, Results, User Notification Email, and PDF. Note that you can move the required variable by clicking on the respective variable's Move (+) icon.

All Variable

8. B. Once the required variable is moved to Selected Variable, you can rename it as required. In the example provided, we renamed the choices.0.text variable to Prompt Response. Click on Submit to save the changes.

Choose Variables

9. You can now use the fetched variables in Questions, on the Outcome/Result page, in the Formula Builder, in User Notification Email, and PDF. The variable can be added by clicking the Add Variable option.

Add Variable

10. Finally, make sure you click on Publish to save the changes made to the content. Once the changes are saved, you can use only the live link of your content to test the changes.

Publish to save

If you have any questions or need further assistance, please contact us at [email protected], and our team will be happy to help you find a solution.

πŸ“˜

Things to keep in mind

1. You can enable Call API feature for each question seperately, and can fetch or post data to seperate 3rd party tool.

2. Using Google Distance Matrix API, you can fetch distance or travel time related data for cities within the same country.