> ## Documentation Index
> Fetch the complete documentation index at: https://radarlabs-jasonliu-test.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# mParticle

<Info>
  The mParticle integration is available on the [**Enterprise plan**](https://radar.com/pricing).
</Info>

Radar can send events and user attributes to [mParticle](https://www.mparticle.com) as an input feed. You can use events and user attributes to build audiences in mParticle, and mParticle can send events and user attributes to hundreds of outputs.

The mParticle SDK can also install and initialize the [Radar SDK](/sdk/sdk) as a kit.

Use the mParticle integration to build location-based audiences and to forward location events and user context to any outputs.

## Configuration

### Feed

To configure the feed, in mParticle, add Radar input feeds for iOS and Android and copy your API keys and secrets.

Then, on the Radar [Integrations page](https://dashboard.radar.com/integrations) under *mParticle Feed*, set *Enabled* to *Yes* and paste your API keys and secrets.

Whenever events are generated, Radar will send events and user attributes to mParticle. Events and user attributes from iOS devices will be sent to the iOS input feed, and events and user attributes from Android devices will be sent to the Android input feed. The Radar *Test* environment automatically maps to the *Development* environment in mParticle, and the Radar *Live* environment automatically maps to the *Production* environment in mParticle.

By default, Radar sends the IDFV on iOS and Android Id on Android to associate the Radar events with the correct mParticle user. Additionally, the Radar `userId` maps to mParticle `customerid` for logged in users.

You can specify a custom mapping for the mParticle customer ID by setting Radar `metadata.mParticleCustomerId`. For example, on iOS:

```swift theme={null}
// track logged in users with custom userId mapping (not required if using default mapping)
// map by mParticle
CustomerIdRadar.setMetadata(["mParticleCustomerId": customerid])
```

If not leveraging a customer ID in mParticle but there is a need to set the Radar `userId`, collect the mParticle ID and set as Radar `metadata.mParticleId`.

<CodeGroup>
  ```swift Swift theme={null}
  // setting the Radar userId, but not leveraging a customer ID in mParticle

  // map by mParticleId
  let options = MParticleOptions(key: "mp_key_..", secret: "mp_secret_...")
  options.onIdentifyComplete =  {(result: MPIdentityApiResult?, error: Error?) in
    if (result?.user != nil) {
      if let mpId = result?.user.userId {
        let radarMetadata = ["mParticleId":mpId]
        Radar.setMetadata(radarMetadata)
      }
    } else {
      // handle failure
    }
  }

  MParticle.sharedInstance().start(with: options)
  ```

  ```kotlin Kotlin theme={null}
  // setting the Radar userId, but not leveraging a customer ID in mParticle

  // map by mParticleId
  MParticle.getInstance()?.Identity()?.addIdentityStateListener { user, _ ->
    val mParticleId = user.id
    var radarMetadata = JSONObject()
    radarMetadata.put("mParticleId",mParticleId)
    Radar.setMetadata(radarMetadata)
  }
  ```
</CodeGroup>

### Kit

To configure the kit, on the Radar [Settings page](https://dashboard.radar.com/settings) under *Keys*, copy your test and live publishable keys. Then, in mParticle, add and enable Radar outputs for iOS and Android, paste your keys, and choose whether to run automatically.

Install the kit using CocoaPods or Carthage on iOS and Gradle on Android. See the [iOS kit code and readme](https://github.com/mparticle-integrations/mparticle-apple-integration-radar), [Android kit code and readme](https://github.com/mparticle-integrations/mparticle-android-integration-radar), and [mParticle Kit documentation for Radar](https://docs.mparticle.com/integrations/radar/event/).

The kit will initialize the [Radar SDK](/sdk/sdk) and identify the user with the mParticle customer ID. After version `8.0.2` of the iOS kit and `5.15.1` of the Android kit, Radar will also set `metadata.mParticleId` to the [MPID](https://docs.mparticle.com/developers/sdk/web/users/#mparticle-id). In addition, if you chose to run automatically and the user has granted permissions, the kit will automatically track the user's location in the foreground on app open and/or in the background.

## User mapping

Note that Radar uses the special string `"(null)"` to represent `null` user attribute values.

| Radar User Field                           | mParticle User Attribute                      | Type           | Example Value                              | Context Type                       |
| ------------------------------------------ | --------------------------------------------- | -------------- | ------------------------------------------ | ---------------------------------- |
| `metadata.mParticleId`                     | `mpid`                                        | string         | `"4294967296"`                             |                                    |
| `metadata.mParticleCustomerId` or `userId` | `customerid`                                  | string         | `"1"`                                      |                                    |
| `deviceId`                                 | `ios_idfv` or `android_uuid`                  | string         | `"10974a2ee035770b9"`                      |                                    |
| `location.coordinates[0]`                  | `radar_location_longitude`                    | number         | `-76.350663`                               |                                    |
| `location.coordinates[1]`                  | `radar_location_latitude`                     | number         | `39.525665`                                |                                    |
| `locationAuthorization`                    | `radar_location_authorization`                | string         | `"GRANTED_FOREGROUND"`                     |                                    |
| `locationAccuracyAuthorization`            | `radar_location_accuracy_authorization`       | string         | `"FULL"`                                   |                                    |
| `_id`                                      | `radar_id`                                    | string         | `"5b2c0906f5874b001aecfd8d"`               |                                    |
| `updatedAt`                                | `radar_updated_at`                            | timestamp      | `"2018-06-22T15:23:39.000Z"`               |                                    |
| `segments[*].externalId`                   | `radar_segment_external_ids`                  | array\[string] | `["starbucks-visitors"]`                   |                                    |
| `topChains[*].slug`                        | `radar_top_chain_slugs`                       | array\[string] | `["starbucks", "walmart"]`                 |                                    |
| `topChains[*].externalId`                  | `radar_top_chain_external_ids`                | array\[string] | `["123", "456"]`                           |                                    |
| `geofences[*]._id`                         | `radar_geofence_ids`                          | array\[string] | `["5b2c0906f5874b001aecfd8e"]`             | [Geofences](/geofencing/geofences) |
| `geofences[*].description`                 | `radar_geofence_descriptions`                 | array\[string] | `["Store #123"]`                           | [Geofences](/geofencing/geofences) |
| `geofences[*].tag`                         | `radar_geofence_tags`                         | array\[string] | `["store"]`                                | [Geofences](/geofencing/geofences) |
| `geofences[*].externalId`                  | `radar_geofence_external_ids`                 | array\[string] | `["123"]`                                  | [Geofences](/geofencing/geofences) |
| `place._id`                                | `radar_place_id`                              | string         | `"59302bcf8f27e8a156bd4f91"`               | [Places](/geofencing/places)       |
| `place.name`                               | `radar_place_name`                            | string         | `"Starbucks"`                              | [Places](/geofencing/places)       |
| `place.categories`                         | `radar_place_categories`                      | array\[string] | `["food-beverage", "cafe", "coffee-shop"]` | [Places](/geofencing/places)       |
| `place.chain.slug`                         | `radar_place_chain_slug`                      | string         | `"starbucks"`                              | [Places](/geofencing/places)       |
| `place.chain.name`                         | `radar_place_chain_name`                      | string         | `"Starbucks"`                              | [Places](/geofencing/places)       |
| `country.code`                             | `radar_region_country_code`                   | string         | `"US"`                                     | [Regions](/geofencing/regions)     |
| `country.name`                             | `radar_region_country_name`                   | string         | `"United States"`                          | [Regions](/geofencing/regions)     |
| `state.code`                               | `radar_region_state_code`                     | string         | `"MD"`                                     | [Regions](/geofencing/regions)     |
| `state.name`                               | `radar_region_state_name`                     | string         | `"Maryland"`                               | [Regions](/geofencing/regions)     |
| `dma.code`                                 | `radar_region_dma_code`                       | string         | `"26"`                                     | [Regions](/geofencing/regions)     |
| `dma.name`                                 | `radar_region_dma_name`                       | string         | `"Baltimore"`                              | [Regions](/geofencing/regions)     |
| `postalCode.code`                          | `radar_region_postal_code`                    | string         | `"21014"`                                  | [Regions](/geofencing/regions)     |
| `trip.externalId`                          | `radar_trip_external_id`                      | string         | `"299"`                                    | [Trip Tracking](/geofencing/trips) |
| `trip.destinationGeofenceTag`              | `radar_trip_destination_geofence_tag`         | string         | `"store"`                                  | [Trip Tracking](/geofencing/trips) |
| `trip.destinationGeofenceExternalId`       | `radar_trip_destination_geofence_external_id` | string         | `"123"`                                    | [Trip Tracking](/geofencing/trips) |
| `beacons[*]._id`                           | `radar_beacon_ids`                            | array\[string] | `["5b2c0906f5874b001aecfd8f]"`             | [Beacons](/geofencing/beacons)     |
| `beacons[*].description`                   | `radar_beacon_descriptions`                   | array\[string] | `["Store #123 - Drive-Thru"]`              | [Beacons](/geofencing/beacons)     |
| `beacons[*].tag`                           | `radar_beacon_tags`                           | array\[string] | `["drive-thru"]`                           | [Beacons](/geofencing/beacons)     |
| `beacons[*].externalId`                    | `radar_beacon_external_ids`                   | array\[string] | `["123"]`                                  | [Beacons](/geofencing/beacons)     |

## Event mapping

### user.entered\_geofence

| Radar Event Field          | mParticle Event Attribute | Type    | Example Value                |
| -------------------------- | ------------------------- | ------- | ---------------------------- |
| `geofence._id`             | `geofence_id`             | string  | `"5b2c0906f5874b001aecfd8e"` |
| `geofence.description`     | `geofence_description`    | string  | `"Store #123"`               |
| `geofence.tag`             | `geofence_tag`            | string  | `"store"`                    |
| `geofence.externalId`      | `geofence_external_id`    | string  | `"123"`                      |
| `geofence.metadata[{key}]` | `geofence_metadata_{key}` | type    | `{value}`                    |
| `confidence`               | `confidence`              | string  | `"high"`                     |
| `foreground`               | `foreground`              | boolean | `true`                       |

### user.exited\_geofence

| Radar Event Field          | mParticle Event Attribute | Type             | Example Value                |
| -------------------------- | ------------------------- | ---------------- | ---------------------------- |
| `geofence._id`             | `geofence_id`             | string           | `"5b2c0906f5874b001aecfd8e"` |
| `geofence.description`     | `geofence_description`    | string           | `"Store #123"`               |
| `geofence.tag`             | `geofence_tag`            | string           | `"store"`                    |
| `geofence.externalId`      | `geofence_external_id`    | string           | `"123"`                      |
| `geofence.metadata[{key}]` | `geofence_metadata_{key}` | type             | `{value}`                    |
| `confidence`               | `confidence`              | string           | `"high"`                     |
| `duration`                 | `duration`                | number (minutes) | `42.1`                       |
| `foreground`               | `foreground`              | boolean          | `true`                       |

### user.dwelled\_in\_geofence

| Radar Event Field          | mParticle Event Attribute | Type             | Example Value                |
| -------------------------- | ------------------------- | ---------------- | ---------------------------- |
| `geofence._id`             | `geofence_id`             | string           | `"5b2c0906f5874b001aecfd8e"` |
| `geofence.description`     | `geofence_description`    | string           | `"Store #123"`               |
| `geofence.tag`             | `geofence_tag`            | string           | `"store"`                    |
| `geofence.externalId`      | `geofence_external_id`    | string           | `"123"`                      |
| `geofence.metadata[{key}]` | `geofence_metadata_{key}` | type             | `{value}`                    |
| `confidence`               | `confidence`              | string           | `"high"`                     |
| `duration`                 | `duration`                | number (minutes) | `5`                          |
| `foreground`               | `foreground`              | boolean          | `true`                       |

### user.entered\_place

| Radar Event Field  | mParticle Event Attribute | Type                     | Example Value                      |
| ------------------ | ------------------------- | ------------------------ | ---------------------------------- |
| `place._id`        | `place_id`                | string                   | `"59302bcf8f27e8a156bd4f91"`       |
| `place.name`       | `place_name`              | string                   | `"Starbucks"`                      |
| `place.chain.slug` | `place_chain_slug`        | string                   | `"starbucks"`                      |
| `place.chain.name` | `place_chain_name`        | string                   | `"Starbucks"`                      |
| `place.categories` | `place_categories`        | string (comma-separated) | `"food-beverage,cafe,coffee-shop"` |
| `confidence`       | `confidence`              | string                   | `"high"`                           |
| `foreground`       | `foreground`              | boolean                  | `true`                             |

### user.exited\_place

| Radar Event Field  | mParticle Event Attribute | Type                     | Example Value                      |
| ------------------ | ------------------------- | ------------------------ | ---------------------------------- |
| `place._id`        | `place_id`                | string                   | `"59302bcf8f27e8a156bd4f91"`       |
| `place.name`       | `place_name`              | string                   | `"Target"`                         |
| `place.chain.slug` | `place_chain_slug`        | string                   | `"target"`                         |
| `place.chain.name` | `place_chain_name`        | string                   | `"Target"`                         |
| `place.categories` | `place_categories`        | string (comma-separated) | `"food-beverage,cafe,coffee-shop"` |
| `confidence`       | `confidence`              | string                   | `"high"`                           |
| `duration`         | `duration`                | number (minutes)         | `42.1`                             |
| `foreground`       | `foreground`              | boolean                  | `true`                             |

### user.entered\_region\_country

| Radar Event Attribute | mParticle Event Attribute | Type    | Example Value     |
| --------------------- | ------------------------- | ------- | ----------------- |
| `region.code`         | `region_code`             | string  | `"US"`            |
| `region.name`         | `region_name`             | string  | `"United States"` |
| `confidence`          | `confidence`              | string  | `"high"`          |
| `foreground`          | `foreground`              | boolean | `true`            |

### user.exited\_region\_country

| Radar Event Attribute | mParticle Event Attribute | Type    | Example Value     |
| --------------------- | ------------------------- | ------- | ----------------- |
| `region.code`         | `region_code`             | string  | `"US"`            |
| `region.name`         | `region_name`             | string  | `"United States"` |
| `confidence`          | `confidence`              | string  | `"high"`          |
| `foreground`          | `foreground`              | boolean | `true`            |

### user.entered\_region\_state

| Radar Event Attribute | mParticle Event Attribute | Type    | Example Value |
| --------------------- | ------------------------- | ------- | ------------- |
| `region.code`         | `region_code`             | string  | `"MD"`        |
| `region.name`         | `region_name`             | string  | `"Maryland"`  |
| `confidence`          | `confidence`              | string  | `"high"`      |
| `foreground`          | `foreground`              | boolean | `true`        |

### user.exited\_region\_state

| Radar Event Attribute | mParticle Event Attribute | Type    | Example Value |
| --------------------- | ------------------------- | ------- | ------------- |
| `region.code`         | `region_code`             | string  | `"MD"`        |
| `region.name`         | `region_name`             | string  | `"Maryland"`  |
| `confidence`          | `confidence`              | string  | `"high"`      |
| `foreground`          | `foreground`              | boolean | `true`        |

### user.entered\_region\_dma

| Radar Event Attribute | mParticle Event Attribute | Type    | Example Value |
| --------------------- | ------------------------- | ------- | ------------- |
| `region.code`         | `region_code`             | string  | `"26"`        |
| `region.name`         | `region_name`             | string  | `"Baltimore"` |
| `confidence`          | `confidence`              | string  | `"high"`      |
| `foreground`          | `foreground`              | boolean | `true`        |

### user.exited\_region\_dma

| Radar Event Attribute | mParticle Event Attribute | Type    | Example Value |
| --------------------- | ------------------------- | ------- | ------------- |
| `region.code`         | `region_code`             | string  | `"26"`        |
| `region.name`         | `region_name`             | string  | `"Baltimore"` |
| `confidence`          | `confidence`              | string  | `"high"`      |
| `foreground`          | `foreground`              | boolean | `true`        |

### user.started\_trip

| Radar Event Attribute                | mParticle Event Attribute               | Type    | Example Value |
| ------------------------------------ | --------------------------------------- | ------- | ------------- |
| `trip.externalId`                    | `trip_external_id`                      | string  | `"299"`       |
| `trip.metadata[{key}]`               | `trip_metadata_{key}`                   | type    | `{value}`     |
| `trip.destinationGeofenceTag`        | `trip_destination_geofence_tag`         | string  | `"store"`     |
| `trip.destinationGeofenceExternalId` | `trip_destination_geofence_external_id` | string  | `"123"`       |
| `foreground`                         | `foreground`                            | boolean | `true`        |

### user.updated\_trip

| Radar Event Attribute                | mParticle Event Attribute               | Type    | Example Value |
| ------------------------------------ | --------------------------------------- | ------- | ------------- |
| `trip.externalId`                    | `trip_external_id`                      | string  | `"299"`       |
| `trip.metadata[{key}]`               | `trip_metadata_{key}`                   | type    | `{value}`     |
| `trip.destinationGeofenceTag`        | `trip_destination_geofence_tag`         | string  | `"store"`     |
| `trip.destinationGeofenceExternalId` | `trip_destination_geofence_external_id` | string  | `"123"`       |
| `foreground`                         | `foreground`                            | boolean | `true`        |

### user.approaching\_trip\_destination

| Radar Event Attribute                | mParticle Event Attribute               | Type    | Example Value |
| ------------------------------------ | --------------------------------------- | ------- | ------------- |
| `trip.externalId`                    | `trip_external_id`                      | string  | `"299"`       |
| `trip.metadata[{key}]`               | `trip_metadata_{key}`                   | type    | `{value}`     |
| `trip.destinationGeofenceTag`        | `trip_destination_geofence_tag`         | string  | `"store"`     |
| `trip.destinationGeofenceExternalId` | `trip_destination_geofence_external_id` | string  | `"123"`       |
| `foreground`                         | `foreground`                            | boolean | `true`        |

### user.arrived\_at\_trip\_destination

| Radar Event Attribute                | mParticle Event Attribute               | Type    | Example Value |
| ------------------------------------ | --------------------------------------- | ------- | ------------- |
| `trip.externalId`                    | `trip_external_id`                      | string  | `"299"`       |
| `trip.metadata[{key}]`               | `trip_metadata_{key}`                   | type    | `{value}`     |
| `trip.destinationGeofenceTag`        | `trip_destination_geofence_tag`         | string  | `"store"`     |
| `trip.destinationGeofenceExternalId` | `trip_destination_geofence_external_id` | string  | `"123"`       |
| `foreground`                         | `foreground`                            | boolean | `true`        |

### user.stopped\_trip

| Radar Event Attribute                | mParticle Event Attribute               | Type    | Example Value |
| ------------------------------------ | --------------------------------------- | ------- | ------------- |
| `trip.externalId`                    | `trip_external_id`                      | string  | `"299"`       |
| `trip.metadata[{key}]`               | `trip_metadata_{key}`                   | type    | `{value}`     |
| `trip.destinationGeofenceTag`        | `trip_destination_geofence_tag`         | string  | `"store"`     |
| `trip.destinationGeofenceExternalId` | `trip_destination_geofence_external_id` | string  | `"123"`       |
| `foreground`                         | `foreground`                            | boolean | `true`        |

### user.entered\_beacon

| Radar Event Attribute    | mParticle Event Attribute | Type    | Example Value                |
| ------------------------ | ------------------------- | ------- | ---------------------------- |
| `beacon._id`             | `beacon_id`               | string  | `"5b2c0906f5874b001aecfd8f"` |
| `beacon.description`     | `beacon_description`      | string  | `"Store #123 - Drive-Thru"`  |
| `beacon.tag`             | `beacon_tag`              | string  | `"drive-thru"`               |
| `beacon.externalId`      | `beacon_external_id`      | string  | `"123"`                      |
| `beacon.metadata[{key}]` | `beacon_metadata_{key}`   | type    | `{value}`                    |
| `confidence`             | `confidence`              | string  | `"high"`                     |
| `foreground`             | `foreground`              | boolean | `true`                       |

### user.exited\_beacon

| Radar Event Attribute    | mParticle Event Attribute | Type             | Example Value                |
| ------------------------ | ------------------------- | ---------------- | ---------------------------- |
| `beacon._id`             | `beacon_id`               | string           | `"5b2c0906f5874b001aecfd8f"` |
| `beacon.description`     | `beacon_description`      | string           | `"Store #123 - Drive-Thru"`  |
| `beacon.tag`             | `beacon_tag`              | string           | `"drive-thru"`               |
| `beacon.externalId`      | `beacon_external_id`      | string           | `"123"`                      |
| `beacon.metadata[{key}]` | `beacon_metadata_{key}`   | type             | `{value}`                    |
| `confidence`             | `confidence`              | string           | `"high"`                     |
| `duration`               | `duration`                | number (minutes) | `1.42`                       |
| `foreground`             | `foreground`              | boolean          | `true`                       |
