SDK

Contents

Introduction

Integrate the SDK into your iOS and Android apps to start tracking users and generating events. The SDK abstracts away cross-platform differences between location services on iOS and Android, allowing you to add location context and tracking to your apps with just a few lines of code. You can use the SDK to track the user's location in the foreground, in the background, or both.

In the background, the SDK will wake up while the user is moving (usually every 3-5 minutes), then shut down when the user stops (usually within 5-10 minutes). To save battery, the SDK will not wake up when stopped, and the user must move at least 100 meters from a stop to wake up the SDK.

Radar defaults to a balance of accuracy, reliability, responsiveness, and battery efficiency suitable for most use cases. For most users, background tracking uses only 1-2% battery per day.

All geofencing and event generation happens server-side. This allows Radar geofencing to be more powerful than native iOS or Android geofencing, with cross-platform support for unlimited geofences, polygon geofences, stop detection, and accuracy down to 50 meters.

Note that you can use our Toolkit apps for iOS and Android to test Radar before integrating the SDK, or to test your implementation of Radar side-by-side with a complete implementation.

Accuracy and reliability

Smartphone location services are not perfect. On iOS and Android, location services use a combination of GPS, wi-fi scanning, and cell tower scanning to determine the user's location. Accuracy and reliability may be reduced if wi-fi is turned off, especially indoors, or if wi-fi is unavailable, such as in sparse suburban or rural areas.

In addition, accuracy and reliability may be reduced by battery-saving features like iOS Low Power Mode, which restricts background app refresh, Android Doze Mode and App Standby, which restrict wi-fi scanning and network access, and Background Location Limits, which restrict background location updates. To avoid these restrictions on Android, you can start a foreground service.

In general, these constraints apply to all apps and SDKs using location services on iOS and Android, not just Radar. Radar achieves a balance of accuracy, reliability, responsiveness, and battery efficiency suitable for most use cases.

Authentication

Authenticate using your publishable API keys, found on the Settings page. Use your Test Publishable key for testing and non-production environments. Use your Live Publishable key for production environments.

Note that you should always use your publishable API keys, which are restricted in scope, in the SDK. Do not use your secret API keys, which are unrestricted in scope, in any client-side code.

iOS

Learn how to integrate the iOS SDK below. You can also see a detailed SDK reference on GitHub.

Configure project

To track the user's location in the foreground, you must add a string for the NSLocationWhenInUseUsageDescription key in your Info.plist file if you haven't already. This string will be displayed when prompting the user for foreground location permissions.

To track the user's location in the background, you must also add a string for the NSLocationAlwaysUsageDescription (iOS 10 and before) and NSLocationAlwaysAndWhenInUseUsageDescription (iOS 11 and later) keys in your Info.plist file if you haven't already. These strings will be displayed when prompting the user for background location permissions.

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Your iOS 11 and higher background location usage description goes here. e.g., "This app uses your location in the background to recommend places nearby."</string>

<key>NSLocationAlwaysUsageDescription</key>
<string>Your iOS 10 and lower background location usage description goes here. e.g., "This app uses your location in the background to recommend places nearby."</string>

<key>NSLocationWhenInUseUsageDescription</key>
<string>Your foreground location usage description goes here. e.g., "This app uses your location in the foreground to recommend places nearby."</string>

Then, in your project settings, go to Capabilities > Background Modes and turn on Background fetch.

For increased reliability and responsiveness in the background, you should also turn on Location updates. Note that this requires additional justification during App Store review. Learn more below.

<key>UIBackgroundModes</key>
<array>
  <string>fetch</string>
  <string>location</string>
</array>

Add SDK to project

The best way to add the SDK to your project is via CocoaPods or Carthage.

The SDK is small and typically adds less than 500 KB to your compiled app.

CocoaPods

For CocoaPods, add the following to your Podfile:

pod 'RadarSDK', '~> 2.1.0'

Then, run pod install.

Carthage

To include Radar as a github origin in Carthage, add the following to your Cartfile:

github "radarlabs/radar-sdk-ios" ~> 2.1.0

To include Radar as a binary origin in Carthage, add the following to your Cartfile:

binary "https://raw.githubusercontent.com/radarlabs/radar-sdk-ios/master/RadarSDK.json" ~> 2.1.0

Then, run carthage update and drag Build/iOS/RadarSDK.framework into the Linked Frameworks and Libraries section of your target. Do not add the framework as an input to your copy-frameworks run script.

Add manually

You can also add the SDK to your project manually, though this is not recommended. Download the current release, unzip the package, and drag RadarSDK.framework into your Xcode project. It will automatically appear in the Linked Frameworks and Libraries section of your project settings.

Dependencies

The SDK depends on Apple's CoreLocation framework (for location services). In your project settings, go to General > Linked Frameworks and Libraries and add CoreLocation if you haven't already.

The SDK currently supports iOS 9 and higher.

Integrate SDK into app

Initialize SDK

Import the SDK:

Swift Objective-C

import RadarSDK
// modules enabled
@import RadarSDK;

// modules not enabled
#import <RadarSDK/RadarSDK.h>

Initialize the SDK in your AppDelegate class, on the main thread, before calling any other Radar methods. In application:didFinishLaunchingWithOptions:application(_:didFinishLaunchingWithOptions:), call:

Swift Objective-C

Radar.initialize(publishableKey: publishableKey)
[Radar initializeWithPublishableKey:publishableKey];

where publishableKey is a string containing your publishable API key.

Identify user

Until you identify the user, Radar will automatically identify the user by deviceId (IDFV).

To identify the user when logged in, call:

Swift Objective-C

Radar.setUserId(userId)
[Radar setUserId:userId];

where userId is a stable unique ID for the user.

Do not send any PII, like names, email addresses, or publicly available IDs, for userId. See privacy best practices for more information.

To set an optional dictionary of custom metadata for the user, call:

Swift Objective-C

Radar.setMetadata(metadata)
[Radar setMetadata:metadata];

where metadata is a dictionary with up to 16 keys and values of type string, boolean, or number.

Finally, to set an optional description for the user, displayed in the dashboard, call:

Swift Objective-C

Radar.setDescription(description)
[Radar setDescription:description];

You only need to call these methods once, as these settings will be persisted across app sessions.

Request permissions

Radar respects standard iOS location permissions. Before tracking the user's location, the user must have authorized location permissions for the app if they haven't already.

To track the user's location in the foreground, the app's location authorization status must be kCLAuthorizationStatusAuthorizedWhenInUseauthorizedWhenInUse or kCLAuthorizationStatusAuthorizedAlwaysauthorizedAlways.

To track the user's location in the background, the app's location authorization status must be kCLAuthorizationStatusAuthorizedAlwaysauthorizedAlways.

Learn more about requesting permissions here.

Swift Objective-C

self.locationManager = CLLocationManager()

// foreground
self.locationManager.requestWhenInUseAuthorization()

// background
self.locationManager.requestAlwaysAuthorization()
self.locationManager = [CLLocationManager new];

// foreground
[self.locationManager requestWhenInUseAuthorization];

// background
[self.locationManager requestAlwaysAuthorization];

Foreground tracking

Once you have initialized the SDK, you have identified the user, and the user has authorized foreground permissions, you can track the user's location in the foreground.

To track the user's location in the foreground, call:

Swift Objective-C

Radar.trackOnce(completionHandler: { (status: RadarStatus, location: CLLocation?, events: [RadarEvent]?, user: RadarUser?) in
    // do something with status, location, events, user
})
[Radar trackOnceWithCompletionHandler:^(RadarStatus status, CLLocation *location, NSArray<RadarEvent *> *events, RadarUser *user) {
  // do something with status, location, events, user
}];

You may provide an optional completionHandler that receives the request status, the user's location, the events generated, if any, and the user. The request status can be:

  • RadarStatusSuccesssuccess: the request succeeded
  • RadarStatusErrorPublishableKeyerrorPublishableKey: the SDK was not initialized
  • RadarStatusErrorPermissionserrorPermissions: the app's location authorization status is not kCLAuthorizationStatusAuthorizedWhenInUseauthorizedWhenInUse or kCLAuthorizationStatusAuthorizedAlwaysauthorizedAlways
  • RadarStatusErrorLocationerrorLocation: location services were unavailable, or the location request timed out (after 10 seconds)
  • RadarStatusErrorNetworkerrorNetwork: the network was unavailable, or the network connection timed out
  • RadarStatusErrorUnauthorizederrorUnauthorized: the publishable API key is invalid
  • RadarStatusErrorRateLimiterrorRateLimit: exceeded rate limit of 1 request per second per user or 60 requests per hour per user
  • RadarStatusErrorServererrorServer: an internal server error occurred
  • RadarStatusErrorUnknownerrorUnknown: an unknown error occurred

Background tracking

Once you have initialized the SDK and the user has authorized background permissions, you can start tracking the user's location in the background.

To start tracking the user's location in the background with default tracking options, call:

Swift Objective-C

Radar.startTracking()
[Radar startTracking];

Assuming you have configured your project properly, the SDK will wake up while the user is moving (usually every 3-5 minutes), then shut down when the user stops (usually within 5-10 minutes). To save battery, the SDK will not wake up when stopped, and the user must move at least 100 meters from a stop (sometimes more) to wake up the SDK. Note that location updates may be delayed significantly by iOS Low Power Mode, or if the device has connectivity issues, low battery, or wi-fi disabled. These constraints apply to all uses of background location services on iOS, not just Radar. See more about accuracy and reliability.

Optionally, you can use RadarTrackingOptions to configure advanced tracking options. RadarTrackingPriorityResponsiveness.responsiveness is the default priority. To reduce location update frequency, you can use RadarTrackingPriorityEfficiency.efficiency instead.

Swift Objective-C

let trackingOptions = RadarTrackingOptions()
trackingOptions.priority = .responsiveness // use .efficiency instead to reduce location update frequency
trackingOptions.offline = .replayStopped // use .replayOff instead to disable offline replay
trackingOptions.sync = .possibleStateChanges // use .all instead to sync all location updates

Radar.startTracking(trackingOptions)
RadarTrackingOptions *trackingOptions = [RadarTrackingOptions new];
trackingOptions.priority = RadarTrackingPriorityResponsiveness; // use RadarTrackingPriorityEfficiency instead to reduce location update frequency
trackingOptions.offline = RadarTrackingOfflineReplayStopped; // use RadarTrackingOfflineReplayOff instead to disable offline replay
trackingOptions.sync = RadarTrackingSyncPossibleStateChanges; // use RadarTrackingSyncAll instead to sync all location updates

[Radar startTrackingWithOptions:trackingOptions];

To stop tracking the user's location in the background (e.g., when the user logs out), call:

Swift Objective-C

Radar.stopTracking()
[Radar stopTracking];

You only need to call these methods once, as these settings will be persisted across app sessions.

To listen for events or errors client-side in the background, create a class that implements RadarDelegate, then call setDelegate:setDelegate().

Set your RadarDelegate in a codepath that will be initialized and executed in the background. For example, make your AppDelegate implement RadarDelegate, not a ViewController. AppDelegate will be initialized in the background, whereas a ViewController may not be.

Swift Objective-C

class AppDelegate: UIResponder, UIApplicationDelegate, RadarDelegate {

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    Radar.initialize(publishableKey: publishableKey)
    Radar.setDelegate(self)

    return true
  }

  func didReceiveEvents(_ events: [RadarEvent], user: RadarUser) {
    // do something with events, user
  }

  func didUpdateLocation(_ location: CLLocation, user: RadarUser) {
    // do something with location, user
  }

  func didFail(status: RadarStatus) {
    // do something with status
  }

}
@interface AppDelegate : UIResponder <UIApplicationDelegate, RadarDelegate>

@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [Radar initializeWithPublishableKey:publishableKey];
  [Radar setDelegate:self];

  return YES;
}

- (void)didReceiveEvents:(NSArray<RadarEvent *> *)events user:(RadarUser *)user {
  // do something with events, user
}

- (void)didUpdateLocation:(CLLocation *)location user:(RadarUser *)user {
  // do something with location, user
}

- (void)didFailWithStatus:(RadarStatus)status {
  // do something with status
}

@end

To listen for events server-side instead, add a webhook.

Manual tracking

If you want to manage location services yourself, you can manually update the user's location instead by calling:

Swift Objective-C

Radar.updateLocation(location, completionHandler: { (status: RadarStatus, location: CLLocation?, events: [RadarEvent]?, user: RadarUser?) in
    // do something with status, events, user
})
[Radar updateLocation:location withCompletionHandler:^(RadarStatus status, CLLocation *location, NSArray<RadarEvent *> *events, RadarUser *user) {
  // do something with status, events, user
}];

where location is a CLLocation instance with a valid latitude, longitude, and horizontal accuracy. As with trackOnceWithCompletionHandler:trackOnce(completionHandler:), you may provide an optional completionHandler that receives the request status, the user's location, the events generated, if any, and the user.

Verify events

You can accept or reject events after user check-ins or other forms of verification. Event verifications will be used to improve the accuracy and confidence level of future Insights and Places events.

Swift Objective-C

Radar.acceptEventId(event._id, verifiedPlaceId: event.alternatePlaces[0]._id)

Radar.rejectEventId(event._id)
[Radar acceptEventId:event._id withVerifiedPlaceId:event.alternatePlaces[0]._id];

[Radar rejectEventId:event._id];

Submit to App Store

Apple requires that you justify your use of background location. Add something materially similar to the following to the bottom of your App Store description: This app uses background location to (insert use case here). Continued use of background location may decrease battery life.

If you turned on the Location updates background mode, Apple requires additional justification. Add something materially similar to the following to your App Store review notes: This app uses the Radar SDK (https://radar.io) to (insert use case here). The Radar SDK requires the background location mode to support polygon geofences, home and work detection, and nearby place detection, which cannot be accomplished with region monitoring or visit monitoring.

Learn more about this requirement in section 2.5.4 of the App Store Review Guidelines here.

Android

Learn how to integrate the Android SDK below. You can also see a detailed SDK reference on GitHub.

Configure project

Radar uses the Play Services Location library. If you haven't already configured your project for Play Services, follow the instructions here.

Radar requires the following permissions, added automatically by the SDK manifest:

  • ACCESS_FINE_LOCATION, for location services
  • INTERNET and ACCESS_NETWORK_STATE, to send API requests
  • RECEIVE_BOOT_COMPLETED, to restore geofences on boot

If targeting API level 29 or higher, to track the user's location in the background, you must also add the new ACCESS_BACKGROUND_LOCATION permission to your manifest. Learn more about location permissions changes in Android 10.

Add SDK to project

The best way to add the SDK to your project is via Gradle and JCenter in Android Studio. Add the SDK to the dependencies section of your build.gradle file:

dependencies {
  implementation 'io.radar:sdk:2.1.+'
}

The SDK depends on Google's v4 support library version 28.0.0 and higher (to check and request location permissions) and Play Services Location library version 16.0.0 and higher (for location services). These libraries will be automatically included as transitive dependencies. Learn more about managing dependencies in Gradle here.

You can also add the SDK to your project manually, though this is not recommended. Download the current release and unzip the package. The package contains an aar file. In Android Studio, add the SDK as a module using File > New Module > Import .JAR/.AAR Package.

The SDK currently supports API level 16 and higher.

The SDK is small and typically adds less than 500 KB to your compiled app.

Integrate SDK into app

Initialize SDK

Import the SDK:

Java Kotlin

import io.radar.sdk.Radar;
import io.radar.sdk.Radar

Initialize the SDK in your Application class before calling any other Radar methods. In onCreate(), call:

Java Kotlin

Radar.initialize(publishableKey);
Radar.initialize(publishableKey)

where publishableKey is a string containing your publishable API key.

Identify user

Until you identify the user, Radar will automatically identify the user by deviceId (Android ID).

To identify the user when logged in, call:

Java Kotlin

Radar.setUserId(userId);
Radar.userId = userId

where userId is a stable unique ID for the user.

Do not send any PII, like names, email addresses, or publicly available IDs, for userId. See privacy best practices for more information.

To set an optional dictionary of custom metadata for the user, call:

Java Kotlin

Radar.setMetadata(metadata);
Radar.metadata = metadata

where metadata is a JSONObject with up to 16 keys and values of type string, boolean, or number.

Finally, to set an optional description for the user, displayed in the dashboard, call:

Java Kotlin

Radar.setDescription(description);
Radar.description = description

You only need to call these methods once, as these settings will be persisted across app sessions.

Request permissions

Radar respects standard Android location permissions. Before tracking the user's location, the user must have granted location permissions for the app if they haven't already.

To track the user's location in the foreground, Radar requires the ACCESS_FINE_LOCATION permission. Learn more about requesting permissions here.

If targeting API level 29 or higher, to track the user's location in the background, Radar also requires the new ACCESS_BACKGROUND_LOCATION permission. Learn more about location permissions changes in Android 10.

Java Kotlin

// foreground only or targeting API level 28 and lower
ActivityCompat.requestPermissions(activity, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, requestCode)

// background and targeting API level 29 and higher
ActivityCompat.requestPermissions(activity, new String[] { Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION }, requestCode)
// foreground only or targeting API level 28 and lower
ActivityCompat.requestPermissions(activity, arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), requestCode)

// background and targeting API level 29 and higher
ActivityCompat.requestPermissions(activity, arrayOf(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION), requestCode)

Foreground tracking

Once you have initialized the SDK, you have identified the user, and the user has granted permissions, you can track the user's location in the foreground.

To track the user's location in the foreground, call:

Java Kotlin

Radar.trackOnce(new RadarCallback() {
  @Override
  public void onComplete(RadarStatus status, Location location, RadarEvent[] events, RadarUser user) {
    // do something with status, location, events, user
  }
});
Radar.trackOnce { status, location, events, user ->
  // do something with status, location, events, user
}

You may provide an optional instance of RadarCallback with an implementation of onComplete() that receives the request status, the user's location, the events generated, if any, and the user. The request status can be:

  • RadarStatus.SUCCESS: the request succeeded
  • RadarStatus.ERROR_PUBLISHABLE_KEY: the SDK was not initialized
  • RadarStatus.ERROR_PERMISSIONS: the user has not granted location permissions for the app
  • RadarStatus.ERROR_LOCATION: location services were unavailable, or the location request timed out (after 10 seconds)
  • RadarStatus.ERROR_NETWORK: the network was unavailable, or the network connection timed out
  • RadarStatus.ERROR_UNAUTHORIZED: the publishable API key is invalid
  • RadarStatus.ERROR_RATE_LIMIT: exceeded rate limit of 1 request per second per user or 60 requests per hour per user
  • RadarStatus.ERROR_UNKNOWN: an unknown error occurred

Background tracking

Once you have initialized the SDK and the user has granted permissions, you can start tracking the user's location in the background.

To start tracking the user's location in the background with default tracking options, call:

Java Kotlin

Radar.startTracking();
Radar.startTracking()

Assuming you have configured your project properly, the SDK will wake up while the user is moving (usually every 3-5 minutes), then shut down when the user stops (usually within 5-10 minutes). To save battery, the SDK will not wake up when stopped, and the user must move at least 100 meters from a stop (sometimes more) to wake up the SDK. Note that location updates may be delayed significantly by Android Doze Mode and App Standby and Background Location Limits, or if the device has connectivity issues, low battery, or wi-fi disabled. To avoid these restrictions, you can start a foreground service. These constraints apply to all uses of background location services on Android, not just Radar. See more about accuracy and reliability.

Optionally, you can use RadarTrackingOptions to configure advanced tracking options. RadarTrackingPriority.RESPONSIVENESS is the default priority. To reduce location update frequency and guarantee that the SDK never exceeds Android vitals bad behavior thresholds for excessive wakeups or excessive background wi-fi scans, you can use RadarTrackingPriority.EFFICIENCY instead.

Java Kotlin

RadarTrackingOptions trackingOptions = new RadarTrackingOptions.Builder()
      .priority(RadarTrackingPriority.RESPONSIVENESS) // use EFFICIENCY instead to reduce location update frequency
      .offline(RadarTrackingOffline.REPLAY_STOPPED) // use REPLAY_OFF instead to disable offline replay
      .sync(RadarTrackingSync.POSSIBLE_STATE_CHANGES) // use ALL instead to sync all location updates
      .build();

Radar.startTracking(trackingOptions);
val trackingOptions : RadarTrackingOptions = RadarTrackingOptions.Builder()
      .priority(RadarTrackingPriority.RESPONSIVENESS) // use EFFICIENCY instead to reduce location update frequency
      .offline(RadarTrackingOffline.REPLAY_STOPPED) // use REPLAY_OFF instead to disable offline replay
      .sync(RadarTrackingSync.STATE_CHANGES_ONLY) // use ALL instead to sync all location updates
      .build()

Radar.startTracking(trackingOptions)

To stop tracking the user's location in the background (e.g., when the user logs out), call:

Java Kotlin

Radar.stopTracking();
Radar.stopTracking()

You only need to call these methods once, as these settings will be persisted across app sessions.

To listen for events and errors client-side in the background, create a class that extends RadarReceiver. Then, register the receiver by adding a receiver element to the application element in your manifest:

<application android:label="@string/app_name">
  <receiver
      android:name=".MyRadarReceiver"
      android:enabled="true"
      android:exported="false">
      <intent-filter>
          <action android:name="io.radar.sdk.RECEIVED" />
      </intent-filter>
  </receiver>
</application>

Your receiver should implement the following:

Java Kotlin

public class MyRadarReceiver extends RadarReceiver {

  @Override
  public void onEventsReceived(Context context, RadarEvent[] events, RadarUser user) {
    // do something with context, events, user
  }

  @Override
  public void onLocationUpdated(Context context, Location location, RadarUser user) {
    // do something with context, location, user
  }

  @Override
  public void onError(Context context, RadarStatus status) {
    // do something with context, status
  }

}
class MyRadarReceiver: RadarReceiver() {

  override fun onEventsReceived(context: Context, events: Array<RadarEvent>, user: RadarUser) {
    // do something with context, events, user
  }

  override fun onLocationUpdated(context: Context, location: Location, user: RadarUser) {
    // do something with context, location, user
  }

  override fun onError(context: Context, status: RadarStatus) {
    // do something with context, status
  }

}

To listen for events server-side instead, add a webhook.

Manual tracking

If you want to manage location services yourself, you can manually update the user's location instead by calling:

Java Kotlin

Radar.updateLocation(location, new RadarCallback() {
  @Override
  public void onComplete(RadarStatus status, Location location, RadarEvent[] events, RadarUser user) {
    // do something with status, events, user
  }
});
Radar.updateLocation(location) { status, location, events, user ->
  // do something with status, location, events, user
}

where location is a Location instance with a valid latitude, longitude, and accuracy. As with trackOnce(), you may provide an optional instance of RadarCallback with an implementation of onComplete() that receives the request status, the events generated, if any, and the user.

Verify events

You can accept or reject events after user check-ins or other forms of verification. Event verifications will be used to improve the accuracy and confidence level of future Insights and Places events.

Java Kotlin

Radar.acceptEvent(event.getId(), event.alternatePlaces[0].getId());

Radar.rejectEvent(event.getId());
Radar.acceptEvent(event.id, event.alternatePlaces[0].id)

Radar.rejectEvent(event.id)

React Native

Radar has a React Native module for iOS and Android.

See the full documentation and source on GitHub here. Or, get the react-native-radar package on npm here.

import React, { Component } from 'react';
import { AppRegistry, StyleSheet, Text, View } from 'react-native';
import Radar from 'react-native-radar';

export default class MyComponent extends Component {

  componentDidMount() {
    // identify the user and request permissions
    Radar.setUserId(this.state.userId);
    Radar.requestPermissions(true);

    // track the user's location once in the foreground
    Radar.trackOnce().then((result) => {
      // do something with result.events, result.user.geofences
    }).catch((err) => {
      // optionally, do something with err
    });

    // start tracking the user's location in the background
    Radar.startTracking();
  }

}

// receive events
Radar.on('events', (result) => {
  // do something with result.events, result.user
});

// receive location updates
Radar.on('location', (result) => {
  // do something with result.location, result.user
});

// receive errors
Radar.on('error', (err) => {
  // do something with err
});

Web

Radar also has a JavaScript SDK for web. Unlike the React Native module, the JavaScript SDK is designed for use on desktop and mobile web sites and web apps.

See the full documentation and source on GitHub here. Or, get the radar-sdk-js package on npm here.

<script src="https://js.radar.io/v1.1.0/radar.min.js" integrity="sha384-9gzMIZTQDnuwordlQUv+j9r2TDNLAaKXhSk+p/1jZV0tlnDQ8Bu6YVmTbLIG+dRg" crossorigin="anonymous"></script>

<script type="text/javascript">
  Radar.initialize(publishableKey);
  Radar.trackOnce(function(status, location, user, events) {
    if (status === Radar.STATUS.SUCCESS) {
      if (user.place.chain.slug === 'walmart') {
        // do something
      }
    }
  });
</script>

Support

Have questions after reading the documentation? Visit our Help Center. Still have questions? Click the button on the bottom right of any page to chat with us.