Radar offers an API that can be used to determine someone's location based on the known location of the IP or membership in a Cohort. Calls to this API require a key that is generated when you create an Inquiry API through the Radar interface.
Additional documentationRadar offers an API to allow developers to make decisions based on a visitor's membership in a cohort or location. To use this functionality, a small javascript library needs to be loaded onto the webpage. It does not have any dependencies. Alternatively, you could integrate directly with Radar's API.
Before you use the SDK, you need to setup an API configuration. You build your rules in the Radar application and you are returned an API Key that you can use in your integrations. Each configuration will get its own API Key.
6e94ce185a3847cbbc74cfb66c5e4564. This is the value you'll supply when making method calls.Include the library before you call any of the methods. There are no dependencies so it can be placed either in the <head> tag or at the bottom of the page. The library just needs to be loaded before any of it's method calls.
<script src="https://radar-cdn.its.uiowa.edu/radar-js/latest/radar.min.js"></script>
The examples below use jQuery for illustrative purposes. jQuery is not required to use this SDK.
Imagine we have an Geolocation API Inquiry Key 6e94ce185a3847cbbc74cfb66c5e4564 to answer the question if a visitor is coming from an IP known to exist in the state of Iowa and we would like to show some custom context if the visitor is from Iowa. The API call would return a boolean answering the question which you would use to show the content.
This example chains the answer to the API inquiry to any included logic. In this case, calling jQuery to toggle the visibility of content.
<script>
$(function(){
Radar("fc460398d51b47cd88016e203fbc4f34").inquiry(function(answer) {
$("#iowa").toggle( answer );
});
});
</script>
There is also a direct method to toggle content passing in a selector.
<script>
$(function(){
Radar("f2dc0de6c1744b83a2643889ee4f8196").toggle( "#notIowa" );
});
</script>
To make an inquiry for Cohort membership, the setup is pretty much the same. For this example, let's show a DIV if the person is a member of a cohort. This example optionally passes in the hash of a known user to see if they are a member.
<script>
$(function(){
Radar("109e7787398d4ceea565eaaa69e2e068",
{
user_id: "85b4f632d05ed27f9ca37a8102e1713045679cd7"
}
).inquiry(function(answer) {
$("#hawkeye-fan").toggle( answer );
});
});
</script>
There are limited configuration options supported at this time. The options object that can be included in the function call supports the following properties:
| Property | Required | Description | Supported Values |
|---|---|---|---|
user_id |
No | The user_id of a known user. This is a value from the cookie that the Radar tracker places on the browser for users who have been identified. See the Radar documentation for more information. | String of the hashed value |
method |
No | The HTTP method that should be used to make the call to Radar's API. |
POST (default) GET |
host |
No | The host to send API requests to. |
https://apps.its.uiowa.edu (default) https://test.its.uiowa.edu |